Fix setSettings host override

This commit is contained in:
Reckless_Satoshi 2022-11-26 03:22:45 -08:00
parent b4072b95da
commit dccb155cd8
No known key found for this signature in database
GPG Key ID: 9C4585B561315571
2 changed files with 10 additions and 6 deletions

View File

@ -181,7 +181,7 @@ const Main = ({ settings, setSettings }: MainProps): JSX.Element => {
return await data; return await data;
}; };
const fetchInfo = function (setNetwork?: boolean) { const fetchInfo = function () {
setInfo({ ...info, loading: true }); setInfo({ ...info, loading: true });
apiClient.get(baseUrl, '/api/info/').then((data: Info) => { apiClient.get(baseUrl, '/api/info/').then((data: Info) => {
const versionInfo: any = checkVer(data.version.major, data.version.minor, data.version.patch); 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, clientVersion: versionInfo.clientVersion,
loading: false, loading: false,
}); });
// Sets Setting network from coordinator API param if accessing via web
if (setNetwork) {
setSettings({ ...settings, network: data.network });
}
}); });
}; };
useEffect(() => { useEffect(() => {
if (open.stats || open.coordinator || info.coordinatorVersion == 'v?.?.?') { if (open.stats || open.coordinator || info.coordinatorVersion == 'v?.?.?') {
fetchInfo(info.coordinatorVersion == 'v?.?.?'); fetchInfo();
} }
}, [open.stats, open.coordinator]); }, [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 fetchRobot = function ({ keys = false }) {
const requestBody = { const requestBody = {
token_sha256: sha256(robot.token), token_sha256: sha256(robot.token),

View File

@ -50,6 +50,7 @@ class UnsafeAlert extends Component {
render() { render() {
const { t } = this.props; const { t } = this.props;
console.log(this.state);
// If alert is hidden return null // If alert is hidden return null
if (!this.state.show) { if (!this.state.show) {