mirror of
https://github.com/BlueWallet/BlueWallet.git
synced 2025-02-23 23:27:26 +01:00
Merge pull request #2587 from BlueWallet/2544
FIX: During long menmonics import, wallet panels are not scrolled to …
This commit is contained in:
commit
d398934deb
6 changed files with 29 additions and 31 deletions
|
@ -21,7 +21,6 @@ export const BlueStorageProvider = ({ children }) => {
|
|||
const [language, _setLanguage] = useState();
|
||||
const getPreferredCurrencyAsyncStorage = useAsyncStorage(AppStorage.PREFERRED_CURRENCY).getItem;
|
||||
const getLanguageAsyncStorage = useAsyncStorage(AppStorage.LANG).getItem;
|
||||
const [newWalletAdded, setNewWalletAdded] = useState(false);
|
||||
const [isHandOffUseEnabled, setIsHandOffUseEnabled] = useState(false);
|
||||
const [isDrawerListBlurred, _setIsDrawerListBlurred] = useState(false);
|
||||
|
||||
|
@ -213,8 +212,6 @@ export const BlueStorageProvider = ({ children }) => {
|
|||
sleep,
|
||||
setHodlHodlApiKey,
|
||||
createFakeStorage,
|
||||
newWalletAdded,
|
||||
setNewWalletAdded,
|
||||
resetWallets,
|
||||
getHodlHodlApiKey,
|
||||
decryptStorage,
|
||||
|
|
|
@ -27,7 +27,7 @@ const wif = require('wif');
|
|||
const prompt = require('../blue_modules/prompt');
|
||||
|
||||
function WalletImport() {
|
||||
const { wallets, pendingWallets, setPendingWallets, saveToDisk, addWallet, setNewWalletAdded } = useContext(BlueStorageContext);
|
||||
const { wallets, pendingWallets, setPendingWallets, saveToDisk, addWallet } = useContext(BlueStorageContext);
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -53,7 +53,6 @@ function WalletImport() {
|
|||
}
|
||||
addWallet(w);
|
||||
await saveToDisk();
|
||||
setNewWalletAdded(true);
|
||||
A(A.ENUM.CREATED_WALLET);
|
||||
alert(loc.wallets.import_success);
|
||||
Notifications.majorTomToGroundControl(w.getAllExternalAddresses(), [], []);
|
||||
|
|
|
@ -41,7 +41,7 @@ const ButtonSelected = Object.freeze({
|
|||
|
||||
const WalletsAdd = () => {
|
||||
const { colors } = useTheme();
|
||||
const { addWallet, saveToDisk, setNewWalletAdded, isAdancedModeEnabled } = useContext(BlueStorageContext);
|
||||
const { addWallet, saveToDisk, isAdancedModeEnabled } = useContext(BlueStorageContext);
|
||||
const [isLoading, setIsLoading] = useState(true);
|
||||
const [walletBaseURI, setWalletBaseURI] = useState();
|
||||
const [selectedIndex, setSelectedIndex] = useState(0);
|
||||
|
@ -139,7 +139,6 @@ const WalletsAdd = () => {
|
|||
}
|
||||
addWallet(w);
|
||||
await saveToDisk();
|
||||
setNewWalletAdded(true);
|
||||
A(A.ENUM.CREATED_WALLET);
|
||||
ReactNativeHapticFeedback.trigger('notificationSuccess', { ignoreAndroidSystemSettings: false });
|
||||
if (w.type === HDSegwitP2SHWallet.type || w.type === HDSegwitBech32Wallet.type) {
|
||||
|
@ -184,7 +183,6 @@ const WalletsAdd = () => {
|
|||
addWallet(wallet);
|
||||
await saveToDisk();
|
||||
|
||||
setNewWalletAdded(true);
|
||||
A(A.ENUM.CREATED_WALLET);
|
||||
ReactNativeHapticFeedback.trigger('notificationSuccess', { ignoreAndroidSystemSettings: false });
|
||||
navigate('PleaseBackupLNDHub', {
|
||||
|
|
|
@ -50,7 +50,7 @@ const isDesktop = getSystemName() === 'Mac OS X';
|
|||
const staticCache = {};
|
||||
|
||||
const WalletsAddMultisigStep2 = () => {
|
||||
const { addWallet, saveToDisk, setNewWalletAdded } = useContext(BlueStorageContext);
|
||||
const { addWallet, saveToDisk } = useContext(BlueStorageContext);
|
||||
const { colors } = useTheme();
|
||||
|
||||
const navigation = useNavigation();
|
||||
|
@ -195,7 +195,6 @@ const WalletsAddMultisigStep2 = () => {
|
|||
|
||||
addWallet(w);
|
||||
await saveToDisk();
|
||||
setNewWalletAdded(true);
|
||||
A(A.ENUM.CREATED_WALLET);
|
||||
ReactNativeHapticFeedback.trigger('notificationSuccess', { ignoreAndroidSystemSettings: false });
|
||||
navigation.dangerouslyGetParent().goBack();
|
||||
|
|
|
@ -17,12 +17,11 @@ import { BlurView } from '@react-native-community/blur';
|
|||
const DrawerList = props => {
|
||||
console.log('drawerList rendering...');
|
||||
const walletsCarousel = useRef();
|
||||
const { wallets, selectedWallet, pendingWallets, newWalletAdded, setNewWalletAdded, isDrawerListBlurred } = useContext(
|
||||
BlueStorageContext,
|
||||
);
|
||||
const { wallets, selectedWallet, pendingWallets, isDrawerListBlurred } = useContext(BlueStorageContext);
|
||||
const [carouselData, setCarouselData] = useState([]);
|
||||
const height = useWindowDimensions().height;
|
||||
const { colors } = useTheme();
|
||||
const walletsCount = useRef(wallets.length);
|
||||
const stylesHook = StyleSheet.create({
|
||||
root: {
|
||||
backgroundColor: colors.brandingColor,
|
||||
|
@ -38,12 +37,18 @@ const DrawerList = props => {
|
|||
}, [wallets, pendingWallets]);
|
||||
|
||||
useEffect(() => {
|
||||
if (newWalletAdded) {
|
||||
walletsCarousel.current?.snapToItem(carouselData.length - pendingWallets.length - 2);
|
||||
setNewWalletAdded(false);
|
||||
if (walletsCount.current < wallets.length) {
|
||||
walletsCarousel.current?.snapToItem(walletsCount.current);
|
||||
}
|
||||
walletsCount.current = wallets.length;
|
||||
}, [wallets]);
|
||||
|
||||
useEffect(() => {
|
||||
if (pendingWallets.length > 0) {
|
||||
walletsCarousel.current?.snapToItem(carouselData.length - pendingWallets.length);
|
||||
}
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
}, [newWalletAdded]);
|
||||
}, [pendingWallets]);
|
||||
|
||||
const handleClick = index => {
|
||||
console.log('click', index);
|
||||
|
|
|
@ -35,16 +35,9 @@ const WalletsListSections = { CAROUSEL: 'CAROUSEL', LOCALTRADER: 'LOCALTRADER',
|
|||
|
||||
const WalletsList = () => {
|
||||
const walletsCarousel = useRef();
|
||||
const {
|
||||
wallets,
|
||||
pendingWallets,
|
||||
getTransactions,
|
||||
getBalance,
|
||||
refreshAllWalletTransactions,
|
||||
newWalletAdded,
|
||||
setNewWalletAdded,
|
||||
setSelectedWallet,
|
||||
} = useContext(BlueStorageContext);
|
||||
const { wallets, pendingWallets, getTransactions, getBalance, refreshAllWalletTransactions, setSelectedWallet } = useContext(
|
||||
BlueStorageContext,
|
||||
);
|
||||
const { width } = useWindowDimensions();
|
||||
const { colors, scanImage } = useTheme();
|
||||
const { navigate, setOptions } = useNavigation();
|
||||
|
@ -56,6 +49,7 @@ const WalletsList = () => {
|
|||
);
|
||||
const [carouselData, setCarouselData] = useState([]);
|
||||
const dataSource = getTransactions(null, 10);
|
||||
const walletsCount = useRef(wallets.length);
|
||||
|
||||
const stylesHook = StyleSheet.create({
|
||||
walletsListWrapper: {
|
||||
|
@ -96,12 +90,18 @@ const WalletsList = () => {
|
|||
}, [wallets, pendingWallets]);
|
||||
|
||||
useEffect(() => {
|
||||
if (newWalletAdded) {
|
||||
walletsCarousel.current?.snapToItem(carouselData.length - pendingWallets.length - 2);
|
||||
setNewWalletAdded(false);
|
||||
if (walletsCount.current < wallets.length) {
|
||||
walletsCarousel.current?.snapToItem(walletsCount.current);
|
||||
}
|
||||
walletsCount.current = wallets.length;
|
||||
}, [wallets]);
|
||||
|
||||
useEffect(() => {
|
||||
if (pendingWallets.length > 0) {
|
||||
walletsCarousel.current?.snapToItem(carouselData.length - pendingWallets.length);
|
||||
}
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
}, [newWalletAdded]);
|
||||
}, [pendingWallets]);
|
||||
|
||||
const verifyBalance = () => {
|
||||
if (getBalance() !== 0) {
|
||||
|
|
Loading…
Add table
Reference in a new issue