From 4bddd4a77fcc48f1eda5b43d739811b2ab8f76a5 Mon Sep 17 00:00:00 2001 From: Christian Pauly Date: Mon, 5 Dec 2022 09:11:52 +0100 Subject: [PATCH] fix: Setup push on chat list init --- lib/pages/chat_list/chat_list.dart | 1 + lib/utils/background_push.dart | 3 --- lib/widgets/matrix.dart | 8 ++++---- 3 files changed, 5 insertions(+), 7 deletions(-) diff --git a/lib/pages/chat_list/chat_list.dart b/lib/pages/chat_list/chat_list.dart index fb6b2c4f..e730f68c 100644 --- a/lib/pages/chat_list/chat_list.dart +++ b/lib/pages/chat_list/chat_list.dart @@ -360,6 +360,7 @@ class ChatListController extends State }); _checkTorBrowser(); + Matrix.of(context).backgroundPush?.setupPush(); super.initState(); } diff --git a/lib/utils/background_push.dart b/lib/utils/background_push.dart index a9d64aea..18db4caf 100644 --- a/lib/utils/background_push.dart +++ b/lib/utils/background_push.dart @@ -72,8 +72,6 @@ class BackgroundPush { bool upAction = false; BackgroundPush._(this.client) { - onLogin ??= - client.onLoginStateChanged.stream.listen(handleLoginStateChanged); onRoomSync ??= client.onSync.stream .where((s) => s.hasRoomUpdate) .listen((s) => _onClearingPush(getFromServer: false)); @@ -123,7 +121,6 @@ class BackgroundPush { void handleLoginStateChanged(_) => setupPush(); - StreamSubscription? onLogin; StreamSubscription? onRoomSync; void _newFcmToken(String token) { diff --git a/lib/widgets/matrix.dart b/lib/widgets/matrix.dart index 238ccdb2..c8daa829 100644 --- a/lib/widgets/matrix.dart +++ b/lib/widgets/matrix.dart @@ -78,7 +78,7 @@ class MatrixState extends State with WidgetsBindingObserver { String? loginUsername; bool? loginRegistrationSupported; - BackgroundPush? _backgroundPush; + BackgroundPush? backgroundPush; Client get client { if (widget.clients.isEmpty) { @@ -397,7 +397,7 @@ class MatrixState extends State with WidgetsBindingObserver { } if (PlatformInfos.isMobile) { - _backgroundPush = BackgroundPush( + backgroundPush = BackgroundPush( client, context, widget.router, @@ -444,7 +444,7 @@ class MatrixState extends State with WidgetsBindingObserver { client.requestHistoryOnLimitedTimeline = !foreground; if (_firstStartup) { _firstStartup = false; - _backgroundPush?.setupPush(); + backgroundPush?.setupPush(); } } @@ -514,7 +514,7 @@ class MatrixState extends State with WidgetsBindingObserver { client.httpClient.close(); onFocusSub?.cancel(); onBlurSub?.cancel(); - _backgroundPush?.onLogin?.cancel(); + backgroundPush?.onRoomSync?.cancel(); linuxNotifications?.close();