FIX: During long menmonics import, wallet panels are not scrolled to the last temporary gray wallet card #2544

This commit is contained in:
marcosrdz 2021-02-07 22:34:19 -05:00
parent b72e7ae261
commit b935dbca32
5 changed files with 24 additions and 28 deletions

View File

@ -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,

View File

@ -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(), [], []);

View File

@ -51,7 +51,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();
@ -196,7 +196,6 @@ const WalletsAddMultisigStep2 = () => {
addWallet(w);
await saveToDisk();
setNewWalletAdded(true);
A(A.ENUM.CREATED_WALLET);
ReactNativeHapticFeedback.trigger('notificationSuccess', { ignoreAndroidSystemSettings: false });
navigation.dangerouslyGetParent().goBack();

View File

@ -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,16 @@ const DrawerList = props => {
}, [wallets, pendingWallets]);
useEffect(() => {
if (newWalletAdded) {
walletsCarousel.current?.snapToItem(carouselData.length - pendingWallets.length - 2);
setNewWalletAdded(false);
if (pendingWallets.length > 0) {
walletsCarousel.current?.snapToItem(carouselData.length - pendingWallets.length);
} else {
if (walletsCount.current <= wallets.length) {
walletsCarousel.current?.snapToItem(walletsCount.current - 1);
walletsCount.current = wallets.length;
}
}
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [newWalletAdded]);
}, [pendingWallets]);
const handleClick = index => {
console.log('click', index);

View File

@ -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,16 @@ const WalletsList = () => {
}, [wallets, pendingWallets]);
useEffect(() => {
if (newWalletAdded) {
walletsCarousel.current?.snapToItem(carouselData.length - pendingWallets.length - 2);
setNewWalletAdded(false);
if (pendingWallets.length > 0) {
walletsCarousel.current?.snapToItem(carouselData.length - pendingWallets.length);
} else {
if (walletsCount.current <= wallets.length) {
walletsCarousel.current?.snapToItem(walletsCount.current - 1);
walletsCount.current = wallets.length;
}
}
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [newWalletAdded]);
}, [pendingWallets]);
const verifyBalance = () => {
if (getBalance() !== 0) {