mirror of
https://github.com/cake-tech/cake_wallet.git
synced 2025-06-28 20:39:51 +00:00
CW-782: Show error report popup without cooldown (#1739)
* improve exception throwing on broken wallets - put _lastOpenedWallet to avoid issues on windows (file is currently open by) - don't throw corruptedWalletsSeed - instead store it inside of secureStorage - await ExceptionHandler.onError calls where possible to makse sure that popup won't be canceled by some UI element - adjust BaseAlertDialog to be scrollable if the text is too long - add ExceptionHandler.resetLastPopupDate - that can be called when we want to show error report screen (bypassing cooldown) * fix: HiveError: Box has already been closed. * await the alerts to be sure that each one of them is being shown fix typo in secure storage * Update lib/core/backup_service.dart Co-authored-by: Omar Hatem <omarh.ismail1@gmail.com> * address comments on github * don't store seeds in secure storage * fix wallet password * update monero_c update corrupted seeds UI prevent app from crashing when wallet is corrupted * show alert with seeds * Update corrupted wallet UI Fix wallet opening cache * remove unused code --------- Co-authored-by: Omar Hatem <omarh.ismail1@gmail.com>
This commit is contained in:
parent
d8d4190608
commit
17d34beae9
51 changed files with 205 additions and 87 deletions
|
@ -1,5 +1,6 @@
|
|||
import 'dart:io';
|
||||
|
||||
import 'package:cake_wallet/core/secure_storage.dart';
|
||||
import 'package:cake_wallet/entities/preferences_key.dart';
|
||||
import 'package:cake_wallet/generated/i18n.dart';
|
||||
import 'package:cake_wallet/main.dart';
|
||||
|
@ -20,7 +21,7 @@ class ExceptionHandler {
|
|||
static const _coolDownDurationInDays = 7;
|
||||
static File? _file;
|
||||
|
||||
static void _saveException(String? error, StackTrace? stackTrace, {String? library}) async {
|
||||
static Future<void> _saveException(String? error, StackTrace? stackTrace, {String? library}) async {
|
||||
final appDocDir = await getAppDir();
|
||||
|
||||
if (_file == null) {
|
||||
|
@ -90,7 +91,12 @@ class ExceptionHandler {
|
|||
}
|
||||
}
|
||||
|
||||
static void onError(FlutterErrorDetails errorDetails) async {
|
||||
static Future<void> resetLastPopupDate() async {
|
||||
final sharedPrefs = await SharedPreferences.getInstance();
|
||||
await sharedPrefs.setString(PreferencesKey.lastPopupDate, DateTime(1971).toString());
|
||||
}
|
||||
|
||||
static Future<void> onError(FlutterErrorDetails errorDetails) async {
|
||||
if (kDebugMode || kProfileMode) {
|
||||
FlutterError.presentError(errorDetails);
|
||||
debugPrint(errorDetails.toString());
|
||||
|
@ -124,35 +130,40 @@ class ExceptionHandler {
|
|||
}
|
||||
_hasError = true;
|
||||
|
||||
sharedPrefs.setString(PreferencesKey.lastPopupDate, DateTime.now().toString());
|
||||
await sharedPrefs.setString(PreferencesKey.lastPopupDate, DateTime.now().toString());
|
||||
|
||||
WidgetsBinding.instance.addPostFrameCallback(
|
||||
(timeStamp) async {
|
||||
if (navigatorKey.currentContext != null) {
|
||||
await showPopUp<void>(
|
||||
context: navigatorKey.currentContext!,
|
||||
builder: (context) {
|
||||
return AlertWithTwoActions(
|
||||
isDividerExist: true,
|
||||
alertTitle: S.of(context).error,
|
||||
alertContent: S.of(context).error_dialog_content,
|
||||
rightButtonText: S.of(context).send,
|
||||
leftButtonText: S.of(context).do_not_send,
|
||||
actionRightButton: () {
|
||||
Navigator.of(context).pop();
|
||||
_sendExceptionFile();
|
||||
},
|
||||
actionLeftButton: () {
|
||||
Navigator.of(context).pop();
|
||||
},
|
||||
);
|
||||
// Instead of using WidgetsBinding.instance.addPostFrameCallback we
|
||||
// await Future.delayed(Duration.zero), which does essentially the same (
|
||||
// but doesn't wait for actual frame to be rendered), but it allows us to
|
||||
// properly await the execution - which is what we want, without awaiting
|
||||
// other code may call functions like Navigator.pop(), and close the alert
|
||||
// instead of the intended UI.
|
||||
// WidgetsBinding.instance.addPostFrameCallback(
|
||||
// (timeStamp) async {
|
||||
await Future.delayed(Duration.zero);
|
||||
if (navigatorKey.currentContext != null) {
|
||||
await showPopUp<void>(
|
||||
context: navigatorKey.currentContext!,
|
||||
builder: (context) {
|
||||
return AlertWithTwoActions(
|
||||
isDividerExist: true,
|
||||
alertTitle: S.of(context).error,
|
||||
alertContent: S.of(context).error_dialog_content,
|
||||
rightButtonText: S.of(context).send,
|
||||
leftButtonText: S.of(context).do_not_send,
|
||||
actionRightButton: () {
|
||||
Navigator.of(context).pop();
|
||||
_sendExceptionFile();
|
||||
},
|
||||
actionLeftButton: () {
|
||||
Navigator.of(context).pop();
|
||||
},
|
||||
);
|
||||
}
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
_hasError = false;
|
||||
},
|
||||
);
|
||||
_hasError = false;
|
||||
}
|
||||
|
||||
/// Ignore User related errors or system errors
|
||||
|
@ -272,20 +283,18 @@ class ExceptionHandler {
|
|||
};
|
||||
}
|
||||
|
||||
static void showError(String error, {int? delayInSeconds}) async {
|
||||
static Future<void> showError(String error, {int? delayInSeconds}) async {
|
||||
if (_hasError) {
|
||||
return;
|
||||
}
|
||||
_hasError = true;
|
||||
|
||||
if (delayInSeconds != null) {
|
||||
Future.delayed(Duration(seconds: delayInSeconds), () => _showCopyPopup(error));
|
||||
return;
|
||||
}
|
||||
|
||||
WidgetsBinding.instance.addPostFrameCallback(
|
||||
(_) async => _showCopyPopup(error),
|
||||
);
|
||||
await Future.delayed(Duration.zero);
|
||||
await _showCopyPopup(error);
|
||||
}
|
||||
|
||||
static Future<void> _showCopyPopup(String content) async {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue