Fix useffects for book/limit baseurl change, robot open profile and stats.

This commit is contained in:
Reckless_Satoshi 2023-03-04 10:55:24 -08:00
parent 8d4301a0c0
commit 41feb8cf8e
No known key found for this signature in database
GPG Key ID: 9C4585B561315571

View File

@ -263,6 +263,8 @@ export const AppContextProvider = ({
} }
if (baseUrl != '') { if (baseUrl != '') {
setBook({ orders: [], loading: true });
setLimits({ list: [], loading: true });
fetchBook(); fetchBook();
fetchLimits(); fetchLimits();
} }
@ -332,7 +334,9 @@ export const AppContextProvider = ({
useEffect(() => { useEffect(() => {
if (open.stats || open.coordinator || info.coordinatorVersion == 'v?.?.?') { if (open.stats || open.coordinator || info.coordinatorVersion == 'v?.?.?') {
fetchInfo(); if (window.NativeRobosats === undefined || torStatus == '"Done"') {
fetchInfo();
}
} }
}, [open.stats, open.coordinator]); }, [open.stats, open.coordinator]);
@ -473,9 +477,9 @@ export const AppContextProvider = ({
useEffect(() => { useEffect(() => {
if (baseUrl != '' && page != 'robot') { if (baseUrl != '' && page != 'robot') {
if (open.profile || (robot.token && robot.nickname === null)) { if (open.profile && robot.avatarLoaded) {
fetchRobot({ action: 'refresh' }); // refresh/update existing robot fetchRobot({ action: 'refresh' }); // refresh/update existing robot
} else if (robot.token && robot.encPrivKey && robot.pubKey) { } else if (!robot.avatarLoaded && robot.token && robot.encPrivKey && robot.pubKey) {
fetchRobot({ action: 'generate' }); // create new robot with existing token and keys (on network and coordinator change) fetchRobot({ action: 'generate' }); // create new robot with existing token and keys (on network and coordinator change)
} }
} }