Better notifications
This commit is contained in:
parent
2c6a37d37a
commit
c4353bbea6
14 changed files with 296 additions and 25 deletions
|
|
@ -2,8 +2,11 @@ import 'dart:math';
|
|||
|
||||
import 'package:famedlysdk/famedlysdk.dart';
|
||||
import 'package:fluffychat/components/matrix.dart';
|
||||
import 'package:fluffychat/utils/app_route.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import 'chat_list.dart';
|
||||
|
||||
const String defaultHomeserver = "https://matrix.org";
|
||||
|
||||
class LoginPage extends StatefulWidget {
|
||||
|
|
@ -47,6 +50,7 @@ class _LoginPageState extends State<LoginPage> {
|
|||
}
|
||||
|
||||
try {
|
||||
print("[Login] Check server...");
|
||||
setState(() => loading = true);
|
||||
if (!await matrix.client.checkServer(homeserver)) {
|
||||
setState(() => serverError = "Homeserver is not compatible.");
|
||||
|
|
@ -58,6 +62,7 @@ class _LoginPageState extends State<LoginPage> {
|
|||
return setState(() => loading = false);
|
||||
}
|
||||
try {
|
||||
print("[Login] Try to login...");
|
||||
await matrix.client
|
||||
.login(usernameController.text, passwordController.text);
|
||||
} on MatrixException catch (exception) {
|
||||
|
|
@ -67,8 +72,21 @@ class _LoginPageState extends State<LoginPage> {
|
|||
setState(() => passwordError = exception.toString());
|
||||
return setState(() => loading = false);
|
||||
}
|
||||
try {
|
||||
print("[Login] Setup Firebase...");
|
||||
await matrix.setupFirebase();
|
||||
} catch (exception) {
|
||||
print("[Login] Failed to setup Firebase. Logout now...");
|
||||
await matrix.client.logout();
|
||||
matrix.clean();
|
||||
setState(() => passwordError = exception.toString());
|
||||
return setState(() => loading = false);
|
||||
}
|
||||
print("[Login] Store account and go to ChatListView");
|
||||
await Matrix.of(context).saveAccount();
|
||||
setState(() => loading = false);
|
||||
await Navigator.of(context).pushAndRemoveUntil(
|
||||
AppRoute.defaultRoute(context, ChatListView()), (r) => false);
|
||||
}
|
||||
|
||||
@override
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue