[auth] Sync frequently to identify logout early
This commit is contained in:
@@ -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<App> createState() => _AppState();
|
||||
}
|
||||
|
||||
class _AppState extends State<App> with WindowListener, TrayListener {
|
||||
class _AppState extends State<App>
|
||||
with WindowListener, TrayListener, WidgetsBindingObserver {
|
||||
late StreamSubscription<SignedOutEvent> _signedOutEvent;
|
||||
late StreamSubscription<SignedInEvent> _signedInEvent;
|
||||
Locale? locale;
|
||||
@@ -56,6 +58,7 @@ class _AppState extends State<App> with WindowListener, TrayListener {
|
||||
void initState() {
|
||||
initWindowManager();
|
||||
initTrayManager();
|
||||
WidgetsBinding.instance.addObserver(this);
|
||||
|
||||
_signedOutEvent = Bus.instance.on<SignedOutEvent>().listen((event) {
|
||||
if (mounted) {
|
||||
@@ -98,6 +101,16 @@ class _AppState extends State<App> with WindowListener, TrayListener {
|
||||
_signedInEvent.cancel();
|
||||
}
|
||||
|
||||
@override
|
||||
Future<void> 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) {
|
||||
|
||||
Reference in New Issue
Block a user