mirror of
https://github.com/BlueWallet/BlueWallet.git
synced 2025-03-03 20:07:11 +01:00
Merge branch 'master' into biometrics
This commit is contained in:
commit
aad9370281
2 changed files with 11 additions and 18 deletions
|
@ -2,25 +2,15 @@ import AsyncStorage from '@react-native-community/async-storage';
|
|||
const BlueApp = require('../BlueApp');
|
||||
|
||||
export default class OnAppLaunch {
|
||||
static STORAGE_KEY = 'OnAppLaunchKey';
|
||||
static ENABLED_KEY = 'OnAppLaunchEnabledKey';
|
||||
static STORAGE_KEY = 'ONAPP_LAUNCH_SELECTED_DEFAULT_WALLET_KEY';
|
||||
|
||||
static async isViewAllWalletsEnabled() {
|
||||
let isEnabled;
|
||||
try {
|
||||
isEnabled = await AsyncStorage.getItem(OnAppLaunch.ENABLED_KEY);
|
||||
if (!isEnabled) {
|
||||
const selectedDefaultWallet = await OnAppLaunch.getSelectedDefaultWallet();
|
||||
if (!selectedDefaultWallet) {
|
||||
isEnabled = '1';
|
||||
await AsyncStorage.setItem(OnAppLaunch.ENABLED_KEY, isEnabled);
|
||||
}
|
||||
}
|
||||
const selectedDefaultWallet = await AsyncStorage.getItem(OnAppLaunch.STORAGE_KEY);
|
||||
return selectedDefaultWallet === '' || selectedDefaultWallet === null;
|
||||
} catch (_e) {
|
||||
isEnabled = '1';
|
||||
await AsyncStorage.setItem(OnAppLaunch.ENABLED_KEY, isEnabled);
|
||||
return true;
|
||||
}
|
||||
return !!isEnabled;
|
||||
}
|
||||
|
||||
static async setViewAllWalletsEnabled(value) {
|
||||
|
@ -30,8 +20,9 @@ export default class OnAppLaunch {
|
|||
const firstWallet = BlueApp.getWallets()[0];
|
||||
await OnAppLaunch.setSelectedDefaultWallet(firstWallet.getID());
|
||||
}
|
||||
} else {
|
||||
await AsyncStorage.setItem(OnAppLaunch.STORAGE_KEY, '');
|
||||
}
|
||||
await AsyncStorage.setItem(OnAppLaunch.ENABLED_KEY, value === false ? '' : '1');
|
||||
}
|
||||
|
||||
static async getSelectedDefaultWallet() {
|
||||
|
@ -40,8 +31,7 @@ export default class OnAppLaunch {
|
|||
const selectedWalletID = JSON.parse(await AsyncStorage.getItem(OnAppLaunch.STORAGE_KEY));
|
||||
selectedWallet = BlueApp.getWallets().find(wallet => wallet.getID() === selectedWalletID);
|
||||
if (!selectedWallet) {
|
||||
await AsyncStorage.setItem(OnAppLaunch.ENABLED_KEY, '');
|
||||
await AsyncStorage.removeItem(OnAppLaunch.STORAGE_KEY);
|
||||
await AsyncStorage.setItem(OnAppLaunch.STORAGE_KEY, '');
|
||||
}
|
||||
} catch (_e) {
|
||||
return false;
|
||||
|
|
|
@ -13,6 +13,7 @@ import AsyncStorage from '@react-native-community/async-storage';
|
|||
import PropTypes from 'prop-types';
|
||||
import { AppStorage } from '../../class';
|
||||
import Biometric from '../../class/biometrics';
|
||||
const BlueApp = require('../../BlueApp');
|
||||
let loc = require('../../loc');
|
||||
|
||||
export default class Settings extends Component {
|
||||
|
@ -68,7 +69,9 @@ export default class Settings extends Component {
|
|||
<SafeBlueArea forceInset={{ horizontal: 'always' }} style={{ flex: 1 }}>
|
||||
<BlueHeaderDefaultSub leftText={loc.settings.header} rightComponent={null} />
|
||||
<ScrollView maxHeight={450}>
|
||||
<BlueListItem component={TouchableOpacity} onPress={() => this.props.navigation.navigate('DefaultView')} title="On Launch" />
|
||||
{BlueApp.getWallets().length > 1 && (
|
||||
<BlueListItem component={TouchableOpacity} onPress={() => this.props.navigation.navigate('DefaultView')} title="On Launch" />
|
||||
)}
|
||||
<TouchableOpacity onPress={() => this.props.navigation.navigate('EncryptStorage')}>
|
||||
<BlueListItem title={loc.settings.encrypt_storage} />
|
||||
</TouchableOpacity>
|
||||
|
|
Loading…
Add table
Reference in a new issue