fix: Push error message

This commit is contained in:
Christian Pauly 2022-11-04 13:49:23 +01:00
parent ee2d30bebe
commit f3a002d1a3
4 changed files with 28 additions and 25 deletions

View File

@ -2950,5 +2950,6 @@
"number": {} "number": {}
} }
}, },
"hideUnimportantStateEvents": "Hide unimportant state events" "hideUnimportantStateEvents": "Hide unimportant state events",
"doNotShowAgain": "Do not show again"
} }

View File

@ -23,7 +23,7 @@ abstract class AppConfig {
'https://gitlab.com/famedly/fluffychat/-/blob/main/PRIVACY.md'; 'https://gitlab.com/famedly/fluffychat/-/blob/main/PRIVACY.md';
static String get privacyUrl => _privacyUrl; static String get privacyUrl => _privacyUrl;
static const String enablePushTutorial = static const String enablePushTutorial =
'https://www.reddit.com/r/fluffychat/comments/qn6liu/enable_push_notifications_without_google_services/'; 'https://gitlab.com/famedly/fluffychat/-/wikis/Push-Notifications-without-Google-Services';
static const String appId = 'im.fluffychat.FluffyChat'; static const String appId = 'im.fluffychat.FluffyChat';
static const String appOpenUrlScheme = 'im.fluffychat'; static const String appOpenUrlScheme = 'im.fluffychat';
static String _webBaseUrl = 'https://fluffychat.im/web'; static String _webBaseUrl = 'https://fluffychat.im/web';

View File

@ -258,8 +258,11 @@ class BackgroundPush {
if (context == null) { if (context == null) {
return; return;
} }
if (await store.getItemBool(SettingKeys.showNoGoogle, true)) { if (await store.getItemBool(SettingKeys.showNoGoogle, true) != true) {
await loadLocale(); return;
}
await loadLocale();
WidgetsBinding.instance.addPostFrameCallback((_) {
if (PlatformInfos.isAndroid) { if (PlatformInfos.isAndroid) {
onFcmError?.call( onFcmError?.call(
l10n!.noGoogleServicesWarning, l10n!.noGoogleServicesWarning,
@ -267,13 +270,10 @@ class BackgroundPush {
AppConfig.enablePushTutorial, AppConfig.enablePushTutorial,
), ),
); );
return;
} }
onFcmError?.call(l10n!.oopsPushError); onFcmError?.call(l10n!.oopsPushError);
});
if (null == await store.getItem(SettingKeys.showNoGoogle)) {
await store.setItemBool(SettingKeys.showNoGoogle, false);
}
}
} }
Future<void> setupFirebase() async { Future<void> setupFirebase() async {

View File

@ -5,6 +5,7 @@ import 'dart:io';
import 'package:flutter/foundation.dart'; import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:adaptive_dialog/adaptive_dialog.dart';
import 'package:adaptive_theme/adaptive_theme.dart'; import 'package:adaptive_theme/adaptive_theme.dart';
import 'package:collection/collection.dart'; import 'package:collection/collection.dart';
import 'package:desktop_notifications/desktop_notifications.dart'; import 'package:desktop_notifications/desktop_notifications.dart';
@ -400,22 +401,23 @@ class MatrixState extends State<Matrix> with WidgetsBindingObserver {
client, client,
context, context,
widget.router, widget.router,
onFcmError: (errorMsg, {Uri? link}) => Timer( onFcmError: (errorMsg, {Uri? link}) async {
const Duration(seconds: 1), final result = await showOkCancelAlertDialog(
() { barrierDismissible: true,
final banner = SnackBar( context: context,
content: Text(errorMsg), title: L10n.of(context)!.oopsSomethingWentWrong,
duration: const Duration(seconds: 30), message: errorMsg,
action: link == null okLabel:
? null link == null ? L10n.of(context)!.ok : L10n.of(context)!.help,
: SnackBarAction( cancelLabel: L10n.of(context)!.doNotShowAgain,
label: L10n.of(navigatorContext)!.link, );
onPressed: () => launch(link.toString()), if (result == OkCancelResult.ok && link != null) {
), launch(link.toString());
); }
ScaffoldMessenger.of(navigatorContext).showSnackBar(banner); if (result == OkCancelResult.cancel) {
}, await store.setItemBool(SettingKeys.showNoGoogle, true);
), }
},
); );
} }