mirror of
https://github.com/BlueWallet/BlueWallet.git
synced 2025-03-04 04:13:49 +01:00
FIX: Renamed keys
This commit is contained in:
parent
9d91adca19
commit
ac37747f5a
1 changed files with 10 additions and 11 deletions
|
@ -2,24 +2,23 @@ import AsyncStorage from '@react-native-community/async-storage';
|
||||||
const BlueApp = require('../BlueApp');
|
const BlueApp = require('../BlueApp');
|
||||||
|
|
||||||
export default class OnAppLaunch {
|
export default class OnAppLaunch {
|
||||||
static StorageKey = 'OnAppLaunchKey';
|
static STORAGE_KEY = 'OnAppLaunchKey';
|
||||||
static EnabledKey = 'OnAppLaunchEnabledKey';
|
static ENABLED_KEY = 'OnAppLaunchEnabledKey';
|
||||||
|
|
||||||
static async isViewAllWalletsEnabled() {
|
static async isViewAllWalletsEnabled() {
|
||||||
let isEnabled;
|
let isEnabled;
|
||||||
try {
|
try {
|
||||||
const enabled = await AsyncStorage.getItem(OnAppLaunch.EnabledKey);
|
isEnabled = await AsyncStorage.getItem(OnAppLaunch.ENABLED_KEY);
|
||||||
isEnabled = enabled;
|
|
||||||
if (!isEnabled) {
|
if (!isEnabled) {
|
||||||
const selectedDefaultWallet = await OnAppLaunch.getSelectedDefaultWallet();
|
const selectedDefaultWallet = await OnAppLaunch.getSelectedDefaultWallet();
|
||||||
if (!selectedDefaultWallet) {
|
if (!selectedDefaultWallet) {
|
||||||
isEnabled = '1';
|
isEnabled = '1';
|
||||||
await AsyncStorage.setItem(OnAppLaunch.EnabledKey, isEnabled);
|
await AsyncStorage.setItem(OnAppLaunch.ENABLED_KEY, isEnabled);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (_e) {
|
} catch (_e) {
|
||||||
isEnabled = '1';
|
isEnabled = '1';
|
||||||
await AsyncStorage.setItem(OnAppLaunch.EnabledKey, isEnabled);
|
await AsyncStorage.setItem(OnAppLaunch.ENABLED_KEY, isEnabled);
|
||||||
}
|
}
|
||||||
return !!isEnabled;
|
return !!isEnabled;
|
||||||
}
|
}
|
||||||
|
@ -32,17 +31,17 @@ export default class OnAppLaunch {
|
||||||
await OnAppLaunch.setSelectedDefaultWallet(firstWallet.getID());
|
await OnAppLaunch.setSelectedDefaultWallet(firstWallet.getID());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
await AsyncStorage.setItem(OnAppLaunch.EnabledKey, value === false ? '' : '1');
|
await AsyncStorage.setItem(OnAppLaunch.ENABLED_KEY, value === false ? '' : '1');
|
||||||
}
|
}
|
||||||
|
|
||||||
static async getSelectedDefaultWallet() {
|
static async getSelectedDefaultWallet() {
|
||||||
let selectedWallet = false;
|
let selectedWallet = false;
|
||||||
try {
|
try {
|
||||||
const selectedWalletID = JSON.parse(await AsyncStorage.getItem(OnAppLaunch.StorageKey));
|
const selectedWalletID = JSON.parse(await AsyncStorage.getItem(OnAppLaunch.STORAGE_KEY));
|
||||||
selectedWallet = BlueApp.getWallets().find(wallet => wallet.getID() === selectedWalletID);
|
selectedWallet = BlueApp.getWallets().find(wallet => wallet.getID() === selectedWalletID);
|
||||||
if (!selectedWallet) {
|
if (!selectedWallet) {
|
||||||
await AsyncStorage.setItem(OnAppLaunch.EnabledKey, '');
|
await AsyncStorage.setItem(OnAppLaunch.ENABLED_KEY, '');
|
||||||
await AsyncStorage.removeItem(OnAppLaunch.StorageKey);
|
await AsyncStorage.removeItem(OnAppLaunch.STORAGE_KEY);
|
||||||
}
|
}
|
||||||
} catch (_e) {
|
} catch (_e) {
|
||||||
return false;
|
return false;
|
||||||
|
@ -51,6 +50,6 @@ export default class OnAppLaunch {
|
||||||
}
|
}
|
||||||
|
|
||||||
static async setSelectedDefaultWallet(value) {
|
static async setSelectedDefaultWallet(value) {
|
||||||
await AsyncStorage.setItem(OnAppLaunch.StorageKey, JSON.stringify(value));
|
await AsyncStorage.setItem(OnAppLaunch.STORAGE_KEY, JSON.stringify(value));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue