diff --git a/assets/l10n/intl_en.arb b/assets/l10n/intl_en.arb index 06826c30..385936d8 100644 --- a/assets/l10n/intl_en.arb +++ b/assets/l10n/intl_en.arb @@ -2950,5 +2950,6 @@ "number": {} } }, - "hideUnimportantStateEvents": "Hide unimportant state events" + "hideUnimportantStateEvents": "Hide unimportant state events", + "doNotShowAgain": "Do not show again" } diff --git a/lib/config/app_config.dart b/lib/config/app_config.dart index d9bec2bf..41683a6b 100644 --- a/lib/config/app_config.dart +++ b/lib/config/app_config.dart @@ -23,7 +23,7 @@ abstract class AppConfig { 'https://gitlab.com/famedly/fluffychat/-/blob/main/PRIVACY.md'; static String get privacyUrl => _privacyUrl; 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 appOpenUrlScheme = 'im.fluffychat'; static String _webBaseUrl = 'https://fluffychat.im/web'; diff --git a/lib/utils/background_push.dart b/lib/utils/background_push.dart index 14100768..a9d64aea 100644 --- a/lib/utils/background_push.dart +++ b/lib/utils/background_push.dart @@ -258,8 +258,11 @@ class BackgroundPush { if (context == null) { return; } - if (await store.getItemBool(SettingKeys.showNoGoogle, true)) { - await loadLocale(); + if (await store.getItemBool(SettingKeys.showNoGoogle, true) != true) { + return; + } + await loadLocale(); + WidgetsBinding.instance.addPostFrameCallback((_) { if (PlatformInfos.isAndroid) { onFcmError?.call( l10n!.noGoogleServicesWarning, @@ -267,13 +270,10 @@ class BackgroundPush { AppConfig.enablePushTutorial, ), ); + return; } onFcmError?.call(l10n!.oopsPushError); - - if (null == await store.getItem(SettingKeys.showNoGoogle)) { - await store.setItemBool(SettingKeys.showNoGoogle, false); - } - } + }); } Future setupFirebase() async { diff --git a/lib/widgets/matrix.dart b/lib/widgets/matrix.dart index fa8d9fd4..83b173e7 100644 --- a/lib/widgets/matrix.dart +++ b/lib/widgets/matrix.dart @@ -5,6 +5,7 @@ import 'dart:io'; import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; +import 'package:adaptive_dialog/adaptive_dialog.dart'; import 'package:adaptive_theme/adaptive_theme.dart'; import 'package:collection/collection.dart'; import 'package:desktop_notifications/desktop_notifications.dart'; @@ -400,22 +401,23 @@ class MatrixState extends State with WidgetsBindingObserver { client, context, widget.router, - onFcmError: (errorMsg, {Uri? link}) => Timer( - const Duration(seconds: 1), - () { - final banner = SnackBar( - content: Text(errorMsg), - duration: const Duration(seconds: 30), - action: link == null - ? null - : SnackBarAction( - label: L10n.of(navigatorContext)!.link, - onPressed: () => launch(link.toString()), - ), - ); - ScaffoldMessenger.of(navigatorContext).showSnackBar(banner); - }, - ), + onFcmError: (errorMsg, {Uri? link}) async { + final result = await showOkCancelAlertDialog( + barrierDismissible: true, + context: context, + title: L10n.of(context)!.oopsSomethingWentWrong, + message: errorMsg, + okLabel: + link == null ? L10n.of(context)!.ok : L10n.of(context)!.help, + cancelLabel: L10n.of(context)!.doNotShowAgain, + ); + if (result == OkCancelResult.ok && link != null) { + launch(link.toString()); + } + if (result == OkCancelResult.cancel) { + await store.setItemBool(SettingKeys.showNoGoogle, true); + } + }, ); }