mirror of
https://github.com/Qortal/Qortal-Hub.git
synced 2025-04-28 13:57:51 +00:00
fix bug
This commit is contained in:
parent
144f3e26c5
commit
a41e5049ba
@ -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
|
||||
|
||||
|
@ -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)
|
||||
});
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user