From 6b5aadc49263dc7c4a0b02e3fbcdecc11929b821 Mon Sep 17 00:00:00 2001 From: Andrew Gundersen Date: Tue, 8 Mar 2022 07:23:37 -0600 Subject: [PATCH] Applying production bug fixes --- src/account.js | 11 ----------- src/render/components/app.js | 11 ----------- src/render/preload.js | 8 ++------ src/tray.js | 17 ++++++++--------- src/window.js | 4 +--- 5 files changed, 11 insertions(+), 40 deletions(-) diff --git a/src/account.js b/src/account.js index df404d3..e339db2 100644 --- a/src/account.js +++ b/src/account.js @@ -33,17 +33,6 @@ function initAccount() const account = store.get("account"); if (account) launchSession(account); - - for (let i = 0; i < 10; i++) - { - setTimeout(() => { - console.log("Testing Main to Render IPC"); - ipcEmit("test"); - }, 1000 * i) - } - - ipcMain.on("test", () => console.log("Received from Render!")); - } backgroundMitt.on("logout", (reason) => logout(null, reason)); diff --git a/src/render/components/app.js b/src/render/components/app.js index b92cb53..1793563 100644 --- a/src/render/components/app.js +++ b/src/render/components/app.js @@ -32,22 +32,11 @@ const App = ` } -for (let i = 0; i < 30; i++) -{ - setTimeout(() => { - console.log("Testing Render to Main IPC."); - window.mainApi.send("test"); - }, i * 1000); -} - window.mainApi.on("account", (value, reason) => { - console.log(value, reason); if (reason) alert(reason); account.value = value; }); -window.mainApi.on("test", () => console.log("Received from Main!")); - export default App; export { account }; diff --git a/src/render/preload.js b/src/render/preload.js index 8dd441b..adef673 100644 --- a/src/render/preload.js +++ b/src/render/preload.js @@ -7,8 +7,7 @@ const validFromMainChannels = [ "account", "message", "record", - "ws", - "test" + "ws" ]; const validToMain = [ @@ -17,12 +16,9 @@ const validToMain = [ "logout", "encode", "auth", - "nav", - "test" + "nav" ] -console.log("Running Preload!"); - ipcRenderer.setMaxListeners(250); // Expose protected methods that allow the renderer process to use diff --git a/src/tray.js b/src/tray.js index d6991d4..0f8c69f 100644 --- a/src/tray.js +++ b/src/tray.js @@ -5,7 +5,7 @@ const { Tray } = require("electron"); const { backgroundMitt } = require("./utils/emitter"); let tray; -const TRAY_PATH = "./src/assets/tray/"; +const TRAY_PATH = path.join(__dirname, "assets/tray"); /* Current state of recording, playback, and ws connection */ const state = { @@ -19,25 +19,24 @@ const state = { * @param {"recording" | "playback" | "disconnect"} attribute * @param {boolean} newState */ -function updateTray(attribute, newState) { - +function updateTray(attribute, newState) +{ state[attribute] = newState; // convert boolean to number const bi = (b) => b ? 1 : 0; // Make sure we have the icon we're looking for. - tray.setImage( - TRAY_PATH + + tray.setImage(path.join( + TRAY_PATH, `${bi(state.recording)}${bi(state.playback)}${bi(state.disconnect)}` + ".png" - ); - + )); } -function initTray() +function initTray() { - tray = new Tray(TRAY_PATH + "000" + ".png"); + tray = new Tray(path.join(TRAY_PATH, "000.png")); } exports.initTray = initTray; diff --git a/src/window.js b/src/window.js index 3f67a00..767420e 100644 --- a/src/window.js +++ b/src/window.js @@ -30,8 +30,6 @@ function createWin() { if (win) return; - console.log(__dirname); - let pos = store.get("window-position"); if (!pos) pos = { width: 350, height: 750, x: null, y: null } @@ -45,7 +43,7 @@ function createWin() minWidth: 350, minHeight: 500, backgroundColor: "#EBEBEB", - webPreferences: { preload: path.join(__dirname, "/render/preload.js") } + webPreferences: { preload: path.join(__dirname, "render/preload.js") } }) // TODO: find a simpler way to notify platform of user events -- 2.43.0