fix: No push setup

This commit is contained in:
Christian Pauly 2021-05-28 20:32:52 +02:00
parent 6d8c4d470a
commit e300048d3b
4 changed files with 23 additions and 10 deletions

View File

@ -1,4 +1,9 @@
## v0.31.2 - 2021-05-28
### Fixes
* Setting up push was broken
## v0.31.0 - 2021-05-26
### Chore

View File

@ -54,6 +54,7 @@ class BackgroundPush {
GlobalKey<VRouterState> router;
String _fcmToken;
LoginState _loginState;
void Function(String errorMsg) onFcmError;
L10n l10n;
Store _store;
Store get store => _store ??= Store();
@ -68,7 +69,7 @@ class BackgroundPush {
DateTime lastReceivedPush;
BackgroundPush._(this.client) {
BackgroundPush._(this.client, {this.onFcmError}) {
onLogin ??=
client.onLoginStateChanged.stream.listen(handleLoginStateChanged);
onRoomSync ??= client.onSync.stream
@ -95,10 +96,12 @@ class BackgroundPush {
}
factory BackgroundPush(FluffyClient _client, BuildContext _context,
GlobalKey<VRouterState> router) {
GlobalKey<VRouterState> router,
{final void Function(String errorMsg) onFcmError}) {
final instance = BackgroundPush.clientOnly(_client);
instance.context = _context;
instance.router = router;
instance.onFcmError = onFcmError;
instance.fullInit();
return instance;
}
@ -249,12 +252,10 @@ class BackgroundPush {
}
if (await store.getItemBool(SettingKeys.showNoGoogle, true)) {
await loadLocale();
ScaffoldMessenger.of(context).showSnackBar(SnackBar(
content: Text(
PlatformInfos.isAndroid
? l10n.noGoogleServicesWarning
: l10n.oopsPushError,
)));
onFcmError?.call(PlatformInfos.isAndroid
? l10n.noGoogleServicesWarning
: l10n.oopsPushError);
if (null == await store.getItem(SettingKeys.showNoGoogle)) {
await store.setItemBool(SettingKeys.showNoGoogle, false);
}
@ -262,6 +263,7 @@ class BackgroundPush {
}
Future<void> setupFirebase() async {
Logs().v('Setup firebase');
if (_fcmToken?.isEmpty ?? true) {
try {
_fcmToken = await _fcmSharedIsolate.getToken();

View File

@ -354,7 +354,13 @@ class MatrixState extends State<Matrix> with WidgetsBindingObserver {
}
if (PlatformInfos.isMobile) {
_backgroundPush = BackgroundPush(client, navigatorContext, widget.router);
_backgroundPush = BackgroundPush(
client,
context,
widget.router,
onFcmError: (errorMsg) => ScaffoldMessenger.of(context)
.showSnackBar(SnackBar(content: Text(errorMsg))),
);
}
}

View File

@ -1,7 +1,7 @@
name: fluffychat
description: Chat with your friends.
publish_to: none
version: 0.31.1+0
version: 0.31.2+0
environment:
sdk: ">=2.6.0 <3.0.0"