From a41dd4c60fae5835b76e861b8564b7861ea401ca Mon Sep 17 00:00:00 2001 From: krille-chan Date: Sat, 11 Nov 2023 18:33:19 +0100 Subject: [PATCH] chore: Follow up send presences in background fetch mode --- lib/main.dart | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/lib/main.dart b/lib/main.dart index c3dd3466..877f80da 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -30,6 +30,11 @@ void main() async { // currently only supported on Android. if (PlatformInfos.isAndroid && AppLifecycleState.detached == WidgetsBinding.instance.lifecycleState) { + // Do not send online presences when app is in background fetch mode. + for (final client in clients) { + client.syncPresence = PresenceType.offline; + } + // In the background fetch mode we do not want to waste ressources with // starting the Flutter engine but process incoming push notifications. BackgroundPush.clientOnly(clients.first); @@ -87,6 +92,10 @@ class AppStarter with WidgetsBindingObserver { Logs().i( '${AppConfig.applicationName} switches from the detached background-fetch mode to ${state.name} mode. Rendering GUI...', ); + // Switching to foreground mode needs to reenable send online sync presence. + for (final client in clients) { + client.syncPresence = PresenceType.online; + } startGui(clients, store); // We must make sure that the GUI is only started once. guiStarted = true;