mirror of
https://github.com/krille-chan/fluffychat
synced 2024-09-10 03:05:14 +00:00
fix: No push setup
This commit is contained in:
parent
d89783af82
commit
a9be871956
4 changed files with 23 additions and 10 deletions
|
@ -1,4 +1,9 @@
|
|||
|
||||
## v0.31.2 - 2021-05-28
|
||||
|
||||
### Fixes
|
||||
* Setting up push was broken
|
||||
|
||||
## v0.31.0 - 2021-05-26
|
||||
|
||||
### Chore
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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))),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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"
|
||||
|
|
Loading…
Reference in a new issue