mirror of
https://github.com/AppFlowy-IO/AppFlowy.git
synced 2025-07-03 07:05:30 +00:00
30 lines
837 B
Dart
30 lines
837 B
Dart
![]() |
import 'package:appflowy/env/env.dart';
|
||
|
import 'package:appflowy/startup/startup.dart';
|
||
|
import 'package:appflowy/user/application/auth/auth_service.dart';
|
||
|
import 'package:appflowy/user/application/user_auth_listener.dart';
|
||
|
|
||
|
class InitAppFlowyCloudTask extends LaunchTask {
|
||
|
final _authStateListener = UserAuthStateListener();
|
||
|
bool isLoggingOut = false;
|
||
|
|
||
|
@override
|
||
|
Future<void> initialize(LaunchContext context) async {
|
||
|
if (!isAppFlowyCloudEnabled) {
|
||
|
return;
|
||
|
}
|
||
|
|
||
|
_authStateListener.start(
|
||
|
didSignIn: () {
|
||
|
isLoggingOut = false;
|
||
|
},
|
||
|
onInvalidAuth: (message) async {
|
||
|
await getIt<AuthService>().signOut();
|
||
|
// TODO(nathan): Show a dialog to notify the user that the session is expired.
|
||
|
if (!isLoggingOut) {
|
||
|
await runAppFlowy();
|
||
|
}
|
||
|
},
|
||
|
);
|
||
|
}
|
||
|
}
|