mirror of
https://github.com/Qortal/Qortal-Hub.git
synced 2025-04-28 22:07:52 +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 }) => {
|
export const Wallets = ({ setExtState, setRawWallet, rawWallet }) => {
|
||||||
const [wallets, setWallets] = useState([]);
|
const [wallets, setWallets] = useState([]);
|
||||||
const [isLoading, setIsLoading] = useState(false);
|
const [isLoading, setIsLoading] = useState(true);
|
||||||
|
|
||||||
const hasFetchedWalletsRef = useRef(false)
|
|
||||||
const { getRootProps, getInputProps } = useDropzone({
|
const { getRootProps, getInputProps } = useDropzone({
|
||||||
accept: {
|
accept: {
|
||||||
"application/json": [".json"], // Only accept JSON files
|
"application/json": [".json"], // Only accept JSON files
|
||||||
@ -100,7 +99,7 @@ export const Wallets = ({ setExtState, setRawWallet, rawWallet }) => {
|
|||||||
useEffect(()=> {
|
useEffect(()=> {
|
||||||
setIsLoading(true)
|
setIsLoading(true)
|
||||||
getWallets().then((res)=> {
|
getWallets().then((res)=> {
|
||||||
hasFetchedWalletsRef.current = true
|
|
||||||
if(res && Array.isArray(res)){
|
if(res && Array.isArray(res)){
|
||||||
setWallets(res)
|
setWallets(res)
|
||||||
}
|
}
|
||||||
@ -112,10 +111,10 @@ export const Wallets = ({ setExtState, setRawWallet, rawWallet }) => {
|
|||||||
}, [])
|
}, [])
|
||||||
|
|
||||||
useEffect(()=> {
|
useEffect(()=> {
|
||||||
if(hasFetchedWalletsRef.current && wallets && Array.isArray(wallets)){
|
if(!isLoading && wallets && Array.isArray(wallets)){
|
||||||
storeWallets(wallets)
|
storeWallets(wallets)
|
||||||
}
|
}
|
||||||
}, [wallets])
|
}, [wallets, isLoading])
|
||||||
|
|
||||||
if(isLoading) return null
|
if(isLoading) return null
|
||||||
|
|
||||||
|
@ -856,14 +856,14 @@ export async function getWallets() {
|
|||||||
if (res) {
|
if (res) {
|
||||||
return res;
|
return res;
|
||||||
} else {
|
} else {
|
||||||
throw new Error("No wallet saved");
|
return null
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function storeWallets(wallets) {
|
export async function storeWallets(wallets) {
|
||||||
storeData("wallets", wallets)
|
storeData("wallets", wallets)
|
||||||
.catch((error) => {
|
.catch((error) => {
|
||||||
reject(new Error(error.message || "Error saving data"));
|
console.error(error)
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user