mirror of
https://github.com/AppFlowy-IO/AppFlowy.git
synced 2025-07-23 09:01:21 +00:00
36 lines
870 B
Dart
36 lines
870 B
Dart
import 'package:appflowy/env/env.dart';
|
|
import 'package:appflowy/startup/startup.dart';
|
|
import 'package:appflowy/user/application/user_auth_listener.dart';
|
|
import 'package:appflowy_backend/log.dart';
|
|
|
|
class InitAppFlowyCloudTask extends LaunchTask {
|
|
UserAuthStateListener? _authStateListener;
|
|
bool isLoggingOut = false;
|
|
|
|
@override
|
|
Future<void> initialize(LaunchContext context) async {
|
|
if (!isAppFlowyCloudEnabled) {
|
|
return;
|
|
}
|
|
_authStateListener = UserAuthStateListener();
|
|
|
|
_authStateListener?.start(
|
|
didSignIn: () {
|
|
isLoggingOut = false;
|
|
},
|
|
onInvalidAuth: (message) async {
|
|
Log.error(message);
|
|
if (!isLoggingOut) {
|
|
await runAppFlowy();
|
|
}
|
|
},
|
|
);
|
|
}
|
|
|
|
@override
|
|
Future<void> dispose() async {
|
|
await _authStateListener?.stop();
|
|
_authStateListener = null;
|
|
}
|
|
}
|