fix: Enable gotify recommendations
This commit is contained in:
parent
5801cc0d41
commit
26a07d1849
6 changed files with 112 additions and 55 deletions
|
|
@ -16,6 +16,7 @@ abstract class AppConfig {
|
|||
static const Color secondaryColor = Color(0xFF41a2bc);
|
||||
static String _privacyUrl = 'https://fluffychat.im/en/privacy.html';
|
||||
static String get privacyUrl => _privacyUrl;
|
||||
static const String enablePushTutorial = 'https://fluffychat.im/en/push.html';
|
||||
static const String appId = 'im.fluffychat.FluffyChat';
|
||||
static const String appOpenUrlScheme = 'im.fluffychat';
|
||||
static String _webBaseUrl = 'https://fluffychat.im/web';
|
||||
|
|
|
|||
|
|
@ -51,8 +51,7 @@ class BackgroundPush {
|
|||
BuildContext context;
|
||||
GlobalKey<VRouterState> router;
|
||||
String _fcmToken;
|
||||
LoginState _loginState;
|
||||
void Function(String errorMsg) onFcmError;
|
||||
void Function(String errorMsg, {Uri link}) onFcmError;
|
||||
L10n l10n;
|
||||
Store _store;
|
||||
Store get store => _store ??= Store();
|
||||
|
|
@ -95,7 +94,7 @@ class BackgroundPush {
|
|||
|
||||
factory BackgroundPush(
|
||||
Client _client, BuildContext _context, GlobalKey<VRouterState> router,
|
||||
{final void Function(String errorMsg) onFcmError}) {
|
||||
{final void Function(String errorMsg, {Uri link}) onFcmError}) {
|
||||
final instance = BackgroundPush.clientOnly(_client);
|
||||
instance.context = _context;
|
||||
instance.router = router;
|
||||
|
|
@ -109,7 +108,6 @@ class BackgroundPush {
|
|||
}
|
||||
|
||||
void handleLoginStateChanged(LoginState state) {
|
||||
_loginState = state;
|
||||
setupPush();
|
||||
}
|
||||
|
||||
|
|
@ -217,7 +215,7 @@ class BackgroundPush {
|
|||
|
||||
Future<void> setupPush() async {
|
||||
await setupLocalNotificationsPlugin();
|
||||
if (_loginState != LoginState.loggedIn ||
|
||||
if (client.loginState != LoginState.loggedIn ||
|
||||
!PlatformInfos.isMobile ||
|
||||
context == null) {
|
||||
return;
|
||||
|
|
@ -250,9 +248,15 @@ class BackgroundPush {
|
|||
}
|
||||
if (await store.getItemBool(SettingKeys.showNoGoogle, true)) {
|
||||
await loadLocale();
|
||||
onFcmError?.call(PlatformInfos.isAndroid
|
||||
? l10n.noGoogleServicesWarning
|
||||
: l10n.oopsPushError);
|
||||
if (PlatformInfos.isAndroid) {
|
||||
onFcmError?.call(
|
||||
l10n.noGoogleServicesWarning,
|
||||
link: Uri.parse(
|
||||
AppConfig.enablePushTutorial,
|
||||
),
|
||||
);
|
||||
}
|
||||
onFcmError?.call(l10n.oopsPushError);
|
||||
|
||||
if (null == await store.getItem(SettingKeys.showNoGoogle)) {
|
||||
await store.setItemBool(SettingKeys.showNoGoogle, false);
|
||||
|
|
|
|||
|
|
@ -519,8 +519,22 @@ class MatrixState extends State<Matrix> with WidgetsBindingObserver {
|
|||
client,
|
||||
context,
|
||||
widget.router,
|
||||
onFcmError: (errorMsg) => ScaffoldMessenger.of(context)
|
||||
.showSnackBar(SnackBar(content: Text(errorMsg))),
|
||||
onFcmError: (errorMsg, {Uri link}) => Timer(
|
||||
Duration(seconds: 1),
|
||||
() {
|
||||
final banner = SnackBar(
|
||||
content: Text(errorMsg),
|
||||
duration: Duration(seconds: 30),
|
||||
action: link == null
|
||||
? null
|
||||
: SnackBarAction(
|
||||
label: L10n.of(context).link,
|
||||
onPressed: () => launch(link.toString()),
|
||||
),
|
||||
);
|
||||
ScaffoldMessenger.of(navigatorContext).showSnackBar(banner);
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue