From c75ae701200e8a684dc02db9b171143a7ab50bc7 Mon Sep 17 00:00:00 2001 From: Juan Carlos Carmona Calvo Date: Wed, 16 Aug 2023 12:10:19 -0600 Subject: [PATCH] fix: server & chain fixes --- public/electron.js | 48 +++++++++---------- .../loadingscreen/LoadingScreen.tsx | 23 ++++++++- .../serverselectmodal/ServerSelectModal.tsx | 5 +- 3 files changed, 48 insertions(+), 28 deletions(-) diff --git a/public/electron.js b/public/electron.js index adf47135..0dbec01c 100644 --- a/public/electron.js +++ b/public/electron.js @@ -114,18 +114,18 @@ class MenuBuilder { mainWindow.webContents.send("seed"); }, }, - { - label: "&Import Private Keys", - click: () => { - mainWindow.webContents.send("import"); - }, - }, - { - label: "&Export All Private Keys", - click: () => { - mainWindow.webContents.send("exportall"); - }, - }, + //{ + // label: "&Import Private Keys", + // click: () => { + // mainWindow.webContents.send("import"); + // }, + //}, + //{ + // label: "&Export All Private Keys", + // click: () => { + // mainWindow.webContents.send("exportall"); + // }, + //}, { type: "separator" }, { label: "&Pay URI", @@ -184,18 +184,18 @@ class MenuBuilder { mainWindow.webContents.send("seed"); }, }, - { - label: "&Import Private Keys", - click: () => { - mainWindow.webContents.send("import"); - }, - }, - { - label: "&Export All Private Keys", - click: () => { - mainWindow.webContents.send("exportall"); - }, - }, + //{ + // label: "&Import Private Keys", + // click: () => { + // mainWindow.webContents.send("import"); + // }, + //}, + //{ + // label: "&Export All Private Keys", + // click: () => { + // mainWindow.webContents.send("exportall"); + // }, + //}, { type: "separator" }, { label: "&Pay URI", diff --git a/src/components/loadingscreen/LoadingScreen.tsx b/src/components/loadingscreen/LoadingScreen.tsx index 57884860..54e1faa9 100644 --- a/src/components/loadingscreen/LoadingScreen.tsx +++ b/src/components/loadingscreen/LoadingScreen.tsx @@ -133,8 +133,27 @@ class LoadingScreen extends Component { // Try to read the default server const settings = await ipcRenderer.invoke("loadSettings"); - let server = settings?.serveruri || Utils.ZCASH_COMMUNITY; - let chain_name: 'main' | 'test' | 'regtest' = settings?.serverchain_name || 'main'; + console.log(settings); + let server: string, chain_name: 'main' | 'test' | 'regtest'; + if (!settings) { + server = Utils.ZCASH_COMMUNITY; + chain_name = 'main'; + await ipcRenderer.invoke("saveSettings", { key: "serveruri", value: server }); + await ipcRenderer.invoke("saveSettings", { key: "serverchain_name", value: chain_name }); + } else { + if (!settings.serveruri) { + server = Utils.ZCASH_COMMUNITY; + await ipcRenderer.invoke("saveSettings", { key: "serveruri", value: server }); + } else { + server = settings.serveruri; + } + if (!settings.serverchain_name) { + chain_name = 'main'; + await ipcRenderer.invoke("saveSettings", { key: "serverchain_name", value: chain_name }); + } else { + chain_name = settings.serverchain_name; + } + } const newstate = new LoadingScreenState(); Object.assign(newstate, this.state); diff --git a/src/components/serverselectmodal/ServerSelectModal.tsx b/src/components/serverselectmodal/ServerSelectModal.tsx index 9a8864f4..e2a235b6 100644 --- a/src/components/serverselectmodal/ServerSelectModal.tsx +++ b/src/components/serverselectmodal/ServerSelectModal.tsx @@ -50,8 +50,9 @@ export default function ServerSelectModal({ closeModal, openErrorModal }: ModalP useEffect(() => { (async () => { const settings = await ipcRenderer.invoke("loadSettings"); - const currServer: string = settings?.serveruri || ""; - const currChain: 'main' | 'test' | 'regtest' | '' = settings?.serverchain_name || ""; + console.log(settings); + const currServer: string = settings?.serveruri || Utils.ZCASH_COMMUNITY; + const currChain: 'main' | 'test' | 'regtest' | '' = settings?.serverchain_name || "main"; initialServerValue(currServer, currChain); setServer(currServer); setChain(currChain);