This commit is contained in:
PhilReact 2024-11-19 08:34:21 +02:00
parent 144f3e26c5
commit a41e5049ba
2 changed files with 6 additions and 7 deletions

View File

@ -20,9 +20,8 @@ const parsefilenameQortal = (filename)=> {
export const Wallets = ({ setExtState, setRawWallet, rawWallet }) => {
const [wallets, setWallets] = useState([]);
const [isLoading, setIsLoading] = useState(false);
const [isLoading, setIsLoading] = useState(true);
const hasFetchedWalletsRef = useRef(false)
const { getRootProps, getInputProps } = useDropzone({
accept: {
"application/json": [".json"], // Only accept JSON files
@ -100,7 +99,7 @@ export const Wallets = ({ setExtState, setRawWallet, rawWallet }) => {
useEffect(()=> {
setIsLoading(true)
getWallets().then((res)=> {
hasFetchedWalletsRef.current = true
if(res && Array.isArray(res)){
setWallets(res)
}
@ -112,10 +111,10 @@ export const Wallets = ({ setExtState, setRawWallet, rawWallet }) => {
}, [])
useEffect(()=> {
if(hasFetchedWalletsRef.current && wallets && Array.isArray(wallets)){
if(!isLoading && wallets && Array.isArray(wallets)){
storeWallets(wallets)
}
}, [wallets])
}, [wallets, isLoading])
if(isLoading) return null

View File

@ -856,14 +856,14 @@ export async function getWallets() {
if (res) {
return res;
} else {
throw new Error("No wallet saved");
return null
}
}
export async function storeWallets(wallets) {
storeData("wallets", wallets)
.catch((error) => {
reject(new Error(error.message || "Error saving data"));
console.error(error)
});
}