fix: sometime on startup, app says you upgraded dataVersion (but no) and forget your safes...
This commit is contained in:
parent
71d222307b
commit
d1194d5eb5
|
@ -58,8 +58,11 @@ Future<void> main() async {
|
|||
|
||||
HomeProvider homeProvider = HomeProvider();
|
||||
// DuniterIndexer _duniterIndexer = DuniterIndexer();
|
||||
|
||||
await initHiveForFlutter();
|
||||
await homeProvider.initHive();
|
||||
configBox = await Hive.openBox("configBox");
|
||||
|
||||
appVersion = await homeProvider.getAppVersion();
|
||||
|
||||
// Configure Hive and open boxes
|
||||
|
|
|
@ -47,24 +47,28 @@ class _HomeScreenState extends State<HomeScreen> {
|
|||
final myWalletProvider =
|
||||
Provider.of<MyWalletsProvider>(context, listen: false);
|
||||
|
||||
configBox = await Hive.openBox("configBox");
|
||||
final bool isWalletsExists = myWalletProvider.checkIfWalletExist();
|
||||
|
||||
if (!sub.sdkReady && !sub.sdkLoading) await sub.initApi();
|
||||
if (sub.sdkReady && !sub.nodeConnected) {
|
||||
// Check if versionData non compatible, drop everything
|
||||
if (isWalletsExists &&
|
||||
(configBox.get('dataVersion') ?? 0) < dataVersion) {
|
||||
await infoPopup(context, "chestNotCompatibleMustReinstallGecko".tr());
|
||||
await Hive.deleteBoxFromDisk('walletBox');
|
||||
await Hive.deleteBoxFromDisk('chestBox');
|
||||
chestBox = await Hive.openBox<ChestData>("chestBox");
|
||||
await configBox.delete('defaultWallet');
|
||||
await sub.deleteAllAccounts();
|
||||
configBox.put('dataVersion', dataVersion);
|
||||
myWalletProvider.reload();
|
||||
}
|
||||
// Check if versionData non compatible, drop everything
|
||||
if (configBox.get('dataVersion') == null) {
|
||||
configBox.put('dataVersion', dataVersion);
|
||||
}
|
||||
if (isWalletsExists && (configBox.get('dataVersion')) < dataVersion) {
|
||||
if (!sub.sdkReady && !sub.sdkLoading) sub.initApi();
|
||||
await infoPopup(context, "chestNotCompatibleMustReinstallGecko".tr());
|
||||
await Hive.deleteBoxFromDisk('walletBox');
|
||||
await Hive.deleteBoxFromDisk('chestBox');
|
||||
chestBox = await Hive.openBox<ChestData>("chestBox");
|
||||
await configBox.delete('defaultWallet');
|
||||
if (!sub.sdkReady && !sub.sdkLoading) await sub.initApi();
|
||||
await sub.deleteAllAccounts();
|
||||
configBox.put('dataVersion', dataVersion);
|
||||
myWalletProvider.reload();
|
||||
} else {
|
||||
if (!sub.sdkReady && !sub.sdkLoading) await sub.initApi();
|
||||
}
|
||||
|
||||
if (sub.sdkReady && !sub.nodeConnected) {
|
||||
walletBox = await Hive.openBox<WalletData>("walletBox");
|
||||
await Hive.deleteBoxFromDisk('g1WalletsBox');
|
||||
g1WalletsBox = await Hive.openBox<G1WalletsList>("g1WalletsBox");
|
||||
|
|
Loading…
Reference in New Issue