diff --git a/auth/lib/app/view/app.dart b/auth/lib/app/view/app.dart index 5053f70f12..405ab977ab 100644 --- a/auth/lib/app/view/app.dart +++ b/auth/lib/app/view/app.dart @@ -10,6 +10,7 @@ import 'package:ente_auth/events/signed_out_event.dart'; import "package:ente_auth/l10n/l10n.dart"; import 'package:ente_auth/locale.dart'; import "package:ente_auth/onboarding/view/onboarding_page.dart"; +import 'package:ente_auth/services/authenticator_service.dart'; import 'package:ente_auth/services/update_service.dart'; import 'package:ente_auth/services/user_service.dart'; import 'package:ente_auth/services/window_listener_service.dart'; @@ -34,7 +35,8 @@ class App extends StatefulWidget { State createState() => _AppState(); } -class _AppState extends State with WindowListener, TrayListener { +class _AppState extends State + with WindowListener, TrayListener, WidgetsBindingObserver { late StreamSubscription _signedOutEvent; late StreamSubscription _signedInEvent; Locale? locale; @@ -56,6 +58,7 @@ class _AppState extends State with WindowListener, TrayListener { void initState() { initWindowManager(); initTrayManager(); + WidgetsBinding.instance.addObserver(this); _signedOutEvent = Bus.instance.on().listen((event) { if (mounted) { @@ -98,6 +101,16 @@ class _AppState extends State with WindowListener, TrayListener { _signedInEvent.cancel(); } + @override + Future didChangeAppLifecycleState(AppLifecycleState state) async { + debugPrint("AppLifecycleState: $state"); + if (state == AppLifecycleState.resumed) { + if (Configuration.instance.hasConfiguredAccount()) { + AuthenticatorService.instance.onlineSync().ignore(); + } + } + } + @override Widget build(BuildContext context) { if (Platform.isAndroid || kDebugMode) {