From: riqo Date: Sun, 1 Aug 2021 17:10:10 +0000 (-0500) Subject: fix: remove unused code from preload and config X-Git-Tag: v2.0.1~7^2 X-Git-Url: https://andrewgundersen.net/repos?a=commitdiff_plain;h=refs%2Fheads%2Ficons;p=mime-chat fix: remove unused code from preload and config --- 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) {