From fe2aea6d3c92d3e0d75205c07fa16c2551952d94 Mon Sep 17 00:00:00 2001 From: Christian Pauly Date: Fri, 29 Jul 2022 12:49:26 +0200 Subject: [PATCH] fix: Clearing push triggered when only one room got seen --- lib/main.dart | 1 - lib/utils/client_manager.dart | 1 + lib/utils/push_helper.dart | 9 ++++++--- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/lib/main.dart b/lib/main.dart index dd3b3bd1..91e6579e 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -38,7 +38,6 @@ void main() async { ); final clients = await ClientManager.getClients(); - Logs().level = kReleaseMode ? Level.warning : Level.verbose; if (PlatformInfos.isMobile) { BackgroundPush.clientOnly(clients.first); diff --git a/lib/utils/client_manager.dart b/lib/utils/client_manager.dart index 1acdd096..af80a616 100644 --- a/lib/utils/client_manager.dart +++ b/lib/utils/client_manager.dart @@ -99,6 +99,7 @@ abstract class ClientManager { // To check which story room we can post in EventTypes.RoomPowerLevels, }, + logLevel: kReleaseMode ? Level.warning : Level.verbose, databaseBuilder: FlutterHiveCollectionsDatabase.databaseBuilder, legacyDatabaseBuilder: FlutterFluffyBoxDatabase.databaseBuilder, supportedLoginTypes: { diff --git a/lib/utils/push_helper.dart b/lib/utils/push_helper.dart index f21544fe..1b60c891 100644 --- a/lib/utils/push_helper.dart +++ b/lib/utils/push_helper.dart @@ -51,9 +51,12 @@ Future pushHelper( if (event == null) { Logs().v('Notification is a clearing indicator.'); - await _flutterLocalNotificationsPlugin.cancelAll(); - final store = await SharedPreferences.getInstance(); - await store.setString(SettingKeys.notificationCurrentIds, json.encode({})); + if (notification.counts == null || notification.counts?.unread == 0) { + await _flutterLocalNotificationsPlugin.cancelAll(); + final store = await SharedPreferences.getInstance(); + await store.setString( + SettingKeys.notificationCurrentIds, json.encode({})); + } return; } Logs().v('Push helper got notification event.');