Merge branch 'soru/microg-toast-only-once' into 'master'
Only show the no google services toast once Closes #106 See merge request ChristianPauly/fluffychat-flutter!113
This commit is contained in:
commit
c8d71b8e73
|
@ -81,7 +81,7 @@ class MatrixState extends State<Matrix> {
|
||||||
client.connect();
|
client.connect();
|
||||||
if (await initLoginState == LoginState.logged && !kIsWeb) {
|
if (await initLoginState == LoginState.logged && !kIsWeb) {
|
||||||
await FirebaseController.setupFirebase(
|
await FirebaseController.setupFirebase(
|
||||||
client,
|
this,
|
||||||
widget.clientName,
|
widget.clientName,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,6 +13,7 @@ import 'package:bot_toast/bot_toast.dart';
|
||||||
import 'package:path_provider/path_provider.dart';
|
import 'package:path_provider/path_provider.dart';
|
||||||
import 'package:famedlysdk/famedlysdk.dart';
|
import 'package:famedlysdk/famedlysdk.dart';
|
||||||
import 'famedlysdk_store.dart';
|
import 'famedlysdk_store.dart';
|
||||||
|
import '../components/matrix.dart';
|
||||||
|
|
||||||
abstract class FirebaseController {
|
abstract class FirebaseController {
|
||||||
static final FirebaseMessaging _firebaseMessaging = FirebaseMessaging();
|
static final FirebaseMessaging _firebaseMessaging = FirebaseMessaging();
|
||||||
|
@ -26,7 +27,9 @@ abstract class FirebaseController {
|
||||||
static const String GATEWAY_URL = 'https://janian.de:7023/';
|
static const String GATEWAY_URL = 'https://janian.de:7023/';
|
||||||
static const String PUSHER_FORMAT = 'event_id_only';
|
static const String PUSHER_FORMAT = 'event_id_only';
|
||||||
|
|
||||||
static Future<void> setupFirebase(Client client, String clientName) async {
|
static Future<void> setupFirebase(
|
||||||
|
MatrixState matrix, String clientName) async {
|
||||||
|
final client = matrix.client;
|
||||||
if (Platform.isIOS) iOS_Permission();
|
if (Platform.isIOS) iOS_Permission();
|
||||||
|
|
||||||
String token;
|
String token;
|
||||||
|
@ -36,10 +39,18 @@ abstract class FirebaseController {
|
||||||
token = null;
|
token = null;
|
||||||
}
|
}
|
||||||
if (token?.isEmpty ?? true) {
|
if (token?.isEmpty ?? true) {
|
||||||
BotToast.showText(
|
final storeItem =
|
||||||
text: L10n.of(context).noGoogleServicesWarning,
|
await matrix.store.getItem('chat.fluffy.show_no_google');
|
||||||
duration: Duration(seconds: 15),
|
final configOptionMissing = storeItem == null || storeItem.isEmpty;
|
||||||
);
|
if (configOptionMissing || (!configOptionMissing && storeItem == '1')) {
|
||||||
|
BotToast.showText(
|
||||||
|
text: L10n.of(context).noGoogleServicesWarning,
|
||||||
|
duration: Duration(seconds: 15),
|
||||||
|
);
|
||||||
|
if (configOptionMissing) {
|
||||||
|
await matrix.store.setItem('chat.fluffy.show_no_google', '0');
|
||||||
|
}
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
final pushers = await client.api.requestPushers();
|
final pushers = await client.api.requestPushers();
|
||||||
|
|
|
@ -57,7 +57,7 @@ class _LoginState extends State<Login> {
|
||||||
if (!kIsWeb) {
|
if (!kIsWeb) {
|
||||||
try {
|
try {
|
||||||
await FirebaseController.setupFirebase(
|
await FirebaseController.setupFirebase(
|
||||||
matrix.client,
|
matrix,
|
||||||
matrix.widget.clientName,
|
matrix.widget.clientName,
|
||||||
);
|
);
|
||||||
} catch (exception) {
|
} catch (exception) {
|
||||||
|
|
Loading…
Reference in a new issue