From f96cd7a1bc7c85329a36043aefe0dff44b5a8012 Mon Sep 17 00:00:00 2001 From: riqo Date: Sun, 1 Aug 2021 12:10:10 -0500 Subject: [PATCH] fix: remove unused code from preload and config --- src/config.ts | 1 - src/main.ts | 5 +++-- src/render/preload.ts | 17 +---------------- src/tray.ts | 6 +++--- 4 files changed, 7 insertions(+), 22 deletions(-) diff --git a/src/config.ts b/src/config.ts index ceab21f..ae54af0 100644 --- a/src/config.ts +++ b/src/config.ts @@ -14,5 +14,4 @@ export const config = { BUSINESS_URL: `${BUSINESS_IP}:${BUSINESS_PORT}`, BUSINESS_PREFIX: '/api', configPath: app.getPath('userData'), - appPath: app.getPath('appData') } diff --git a/src/main.ts b/src/main.ts index 588b416..2d9e5fe 100644 --- a/src/main.ts +++ b/src/main.ts @@ -16,15 +16,16 @@ import { initTray } from './tray'; export default async function main() { - /* initiate controls for frontend to use when needed */ + /* initiate render process event listeners & handlers */ initIpcMain(); + /* initiate tray icon in default state */ initTray(); /* launch browser window */ await createWindow(); /* try to authenticate with token */ - await accountAuth(); + accountAuth(); } diff --git a/src/render/preload.ts b/src/render/preload.ts index 3cfbff5..054f672 100644 --- a/src/render/preload.ts +++ b/src/render/preload.ts @@ -1,7 +1,6 @@ // All of the Node.js APIs are available in the preload process. // It has the same sandbox as a Chrome extension. -import { ipcRenderer, Tray, nativeImage } from "electron"; -const path = require('path') +import { ipcRenderer } from "electron"; declare global { interface Window { @@ -13,20 +12,6 @@ window.ipcRenderer = ipcRenderer; process.once("loaded", () => { - const read = path.join(__dirname, 'icon_16x16.png') - console.log(read) - - const imgRead = nativeImage.createFromPath(read) - - let tray = undefined; - - - // Automatic generation of menu - tray = new Tray(imgRead) - - tray.destroy() - tray = new Tray(imgRead) - window.addEventListener("message", event => { // do something with custom event diff --git a/src/tray.ts b/src/tray.ts index 12975f5..7e43c66 100644 --- a/src/tray.ts +++ b/src/tray.ts @@ -60,10 +60,10 @@ function iconFactory(iconName: string): NativeImage { console.log('ERROR: Missing Icons: ', iconName); } // TODO: remove hard code, need icons for different states - let iconBuffer = fs.readFileSync(path.join(__static, TRAY_ICON_DIR, 'icon.png')); + const iconBuffer = fs.readFileSync(path.join(__static, TRAY_ICON_DIR, 'icon.png')); const icon = nativeImage.createFromBuffer(iconBuffer); return icon; -}; +} function updateTray(status: string): void { // read icon state @@ -76,7 +76,7 @@ function updateTray(status: string): void { changeIcon(ICONS.default); } } -}; +} export function initTray(): void { if (!tray) { -- 2.43.0