From dccb155cd8a1a24460e1ba1a7fd699a9309d3584 Mon Sep 17 00:00:00 2001 From: Reckless_Satoshi Date: Sat, 26 Nov 2022 03:22:45 -0800 Subject: [PATCH] Fix setSettings host override --- frontend/src/basic/Main.tsx | 15 +++++++++------ frontend/src/components/UnsafeAlert.js | 1 + 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/frontend/src/basic/Main.tsx b/frontend/src/basic/Main.tsx index 28e03a69..794a8e05 100644 --- a/frontend/src/basic/Main.tsx +++ b/frontend/src/basic/Main.tsx @@ -181,7 +181,7 @@ const Main = ({ settings, setSettings }: MainProps): JSX.Element => { return await data; }; - const fetchInfo = function (setNetwork?: boolean) { + const fetchInfo = function () { setInfo({ ...info, loading: true }); apiClient.get(baseUrl, '/api/info/').then((data: Info) => { const versionInfo: any = checkVer(data.version.major, data.version.minor, data.version.patch); @@ -192,19 +192,22 @@ const Main = ({ settings, setSettings }: MainProps): JSX.Element => { clientVersion: versionInfo.clientVersion, loading: false, }); - // Sets Setting network from coordinator API param if accessing via web - if (setNetwork) { - setSettings({ ...settings, network: data.network }); - } }); }; useEffect(() => { if (open.stats || open.coordinator || info.coordinatorVersion == 'v?.?.?') { - fetchInfo(info.coordinatorVersion == 'v?.?.?'); + fetchInfo(); } }, [open.stats, open.coordinator]); + useEffect(() => { + // Sets Setting network from coordinator API param if accessing via web + if (settings.network == undefined) { + setSettings({ ...settings, network: data.network }); + } + }, [info]); + const fetchRobot = function ({ keys = false }) { const requestBody = { token_sha256: sha256(robot.token), diff --git a/frontend/src/components/UnsafeAlert.js b/frontend/src/components/UnsafeAlert.js index 590437cb..14b75bba 100644 --- a/frontend/src/components/UnsafeAlert.js +++ b/frontend/src/components/UnsafeAlert.js @@ -50,6 +50,7 @@ class UnsafeAlert extends Component { render() { const { t } = this.props; + console.log(this.state); // If alert is hidden return null if (!this.state.show) {