mirror of
https://github.com/cake-tech/cake_wallet.git
synced 2024-11-01 09:57:46 +00:00
5e944a8bf7
Some checks are pending
Cache Dependencies / test (push) Waiting to run
* add litecoin nodes minor ui fix * Try to open the wallet or fetch the seeds and show them to the user * make sure the seeds are only displayed after authentication
46 lines
1.6 KiB
Dart
46 lines
1.6 KiB
Dart
import 'dart:async';
|
|
|
|
import 'package:cake_wallet/routes.dart';
|
|
import 'package:cake_wallet/utils/exception_handler.dart';
|
|
import 'package:flutter/widgets.dart';
|
|
import 'package:mobx/mobx.dart';
|
|
import 'package:cake_wallet/entities/load_current_wallet.dart';
|
|
import 'package:cake_wallet/store/authentication_store.dart';
|
|
|
|
ReactionDisposer? _onAuthenticationStateChange;
|
|
|
|
dynamic loginError;
|
|
StreamController<dynamic> authenticatedErrorStreamController = StreamController<dynamic>();
|
|
|
|
void startAuthenticationStateChange(
|
|
AuthenticationStore authenticationStore, GlobalKey<NavigatorState> navigatorKey) {
|
|
authenticatedErrorStreamController.stream.listen((event) {
|
|
if (authenticationStore.state == AuthenticationState.allowed) {
|
|
ExceptionHandler.showError(event.toString(), delayInSeconds: 3);
|
|
}
|
|
});
|
|
|
|
_onAuthenticationStateChange ??= autorun((_) async {
|
|
final state = authenticationStore.state;
|
|
|
|
if (state == AuthenticationState.installed) {
|
|
try {
|
|
await loadCurrentWallet();
|
|
} catch (error, stack) {
|
|
loginError = error;
|
|
ExceptionHandler.onError(FlutterErrorDetails(exception: error, stack: stack));
|
|
}
|
|
return;
|
|
}
|
|
|
|
if (state == AuthenticationState.allowed) {
|
|
await navigatorKey.currentState!.pushNamedAndRemoveUntil(Routes.dashboard, (route) => false);
|
|
if (!(await authenticatedErrorStreamController.stream.isEmpty)) {
|
|
ExceptionHandler.showError(
|
|
(await authenticatedErrorStreamController.stream.first).toString());
|
|
authenticatedErrorStreamController.stream.drain();
|
|
}
|
|
return;
|
|
}
|
|
});
|
|
}
|