mirror of
https://github.com/BlueWallet/BlueWallet.git
synced 2024-11-19 09:50:15 +01:00
REF: Use Promises instead of await
This commit is contained in:
parent
83ade471e6
commit
4a1d3f0f86
@ -1,4 +1,4 @@
|
||||
import React, { createContext, useState, useContext, useEffect, useMemo, useCallback } from 'react';
|
||||
-import React, { createContext, useState, useContext, useEffect, useMemo, useCallback } from 'react';
|
||||
import { useAsyncStorage } from '@react-native-async-storage/async-storage';
|
||||
import { FiatUnit, TFiatUnit } from '../../models/fiatUnit';
|
||||
import { getPreferredCurrency, initCurrencyDaemon } from '../../blue_modules/currency';
|
||||
@ -89,36 +89,44 @@ export const SettingsProvider: React.FC<{ children: React.ReactNode }> = ({ chil
|
||||
const { walletsInitialized } = useStorage();
|
||||
|
||||
useEffect(() => {
|
||||
const fetchSettings = async () => {
|
||||
const advMode = await advancedModeStorage.getItem();
|
||||
advancedModeStorage.getItem().then(advMode => {
|
||||
console.debug('SettingsContext advMode:', advMode);
|
||||
const handOff = await getIsHandOffUseEnabled();
|
||||
setIsAdvancedModeEnabled(advMode ? JSON.parse(advMode) : false);
|
||||
}).catch(error => console.error('Error fetching advanced mode settings:', error));
|
||||
|
||||
getIsHandOffUseEnabled().then(handOff => {
|
||||
console.debug('SettingsContext handOff:', handOff);
|
||||
setHandOffUseEnabled(handOff);
|
||||
const lang = (await languageStorage.getItem()) ?? 'en';
|
||||
}).catch(error => console.error('Error fetching hand-off usage:', error));
|
||||
|
||||
languageStorage.getItem().then(lang => {
|
||||
lang = lang ?? 'en';
|
||||
console.debug('SettingsContext lang:', lang);
|
||||
setIsAdvancedModeEnabled(advMode ? JSON.parse(advMode) : false);
|
||||
const isBalanceDisplayAllowedStorage = await isBalanceDisplayAllowed();
|
||||
setLanguage(lang);
|
||||
}).catch(error => console.error('Error fetching language setting:', error));
|
||||
|
||||
isBalanceDisplayAllowed().then(isBalanceDisplayAllowedStorage => {
|
||||
console.debug('SettingsContext isBalanceDisplayAllowed:', isBalanceDisplayAllowedStorage);
|
||||
setIsWidgetBalanceDisplayAllowed(isBalanceDisplayAllowedStorage);
|
||||
setLanguage(lang);
|
||||
|
||||
const isURv1EnabledStorage = await isURv1Enabled();
|
||||
}).catch(error => console.error('Error fetching balance display allowance:', error));
|
||||
|
||||
isURv1Enabled().then(isURv1EnabledStorage => {
|
||||
console.debug('SettingsContext isURv1Enabled:', isURv1EnabledStorage);
|
||||
setIsLegacyURv1EnabledStorage(isURv1EnabledStorage);
|
||||
|
||||
const isClipboardGetContentEnabledStorage = await BlueClipboard().isReadClipboardAllowed();
|
||||
}).catch(error => console.error('Error fetching UR v1 enabled status:', error));
|
||||
|
||||
BlueClipboard().isReadClipboardAllowed().then(isClipboardGetContentEnabledStorage => {
|
||||
console.debug('SettingsContext isClipboardGetContentEnabled:', isClipboardGetContentEnabledStorage);
|
||||
setIsClipboardGetContentEnabledStorage(isClipboardGetContentEnabledStorage);
|
||||
|
||||
const isQuickActionsEnabledStorage = await getIsDeviceQuickActionsEnabled();
|
||||
}).catch(error => console.error('Error fetching clipboard content allowance:', error));
|
||||
|
||||
getIsDeviceQuickActionsEnabled().then(isQuickActionsEnabledStorage => {
|
||||
console.debug('SettingsContext isQuickActionsEnabled:', isQuickActionsEnabledStorage);
|
||||
setIsQuickActionsEnabledStorage(isQuickActionsEnabledStorage);
|
||||
};
|
||||
|
||||
fetchSettings();
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
}).catch(error => console.error('Error fetching device quick actions enabled status:', error));
|
||||
|
||||
}, []);
|
||||
|
||||
|
||||
useEffect(() => {
|
||||
if (walletsInitialized) {
|
||||
|
Loading…
Reference in New Issue
Block a user