Skip to content

Commit 8797b08

Browse files
authored
refactor: icon path fn (#1559)
Signed-off-by: Adam Setch <[email protected]>
1 parent c3d2617 commit 8797b08

File tree

1 file changed

+14
-23
lines changed

1 file changed

+14
-23
lines changed

src/electron/main.js

Lines changed: 14 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -17,25 +17,14 @@ const { autoUpdater } = require('electron-updater');
1717
const { updateElectronApp } = require('update-electron-app');
1818

1919
log.initialize();
20+
2021
// Tray Icons
21-
const idleIcon = path.resolve(
22-
`${__dirname}/../../assets/images/tray-idleTemplate.png`,
23-
);
24-
const idleUpdateAvailableIcon = path.resolve(
25-
`${__dirname}/../../assets/images/tray-idle-update.png`,
26-
);
27-
const idleAlternateIcon = path.resolve(
28-
`${__dirname}/../../assets/images/tray-idle-white.png`,
29-
);
30-
const idleAlternateUpdateAvailableIcon = path.resolve(
31-
`${__dirname}/../../assets/images/tray-idle-white-update.png`,
32-
);
33-
const activeIcon = path.resolve(
34-
`${__dirname}/../../assets/images/tray-active.png`,
35-
);
36-
const activeUpdateAvailableIcon = path.resolve(
37-
`${__dirname}/../../assets/images/tray-active-update.png`,
38-
);
22+
const idleIcon = getIconPath('tray-idleTemplate.png');
23+
const idleUpdateIcon = getIconPath('tray-idle-update.png');
24+
const idleAlternateIcon = getIconPath('tray-idle-white.png');
25+
const idleAlternateUpdateIcon = getIconPath('tray-idle-white-update.png');
26+
const activeIcon = getIconPath('tray-active.png');
27+
const activeUpdateIcon = getIconPath('tray-active-update.png');
3928

4029
const browserWindowOpts = {
4130
width: 500,
@@ -192,9 +181,7 @@ app.whenReady().then(async () => {
192181
ipc.on('gitify:icon-active', () => {
193182
if (!mb.tray.isDestroyed()) {
194183
mb.tray.setImage(
195-
updateAvailableMenuItem.visible
196-
? activeUpdateAvailableIcon
197-
: activeIcon,
184+
updateAvailableMenuItem.visible ? activeUpdateIcon : activeIcon,
198185
);
199186
}
200187
});
@@ -204,12 +191,12 @@ app.whenReady().then(async () => {
204191
if (shouldUseAlternateIdleIcon) {
205192
mb.tray.setImage(
206193
updateAvailableMenuItem.visible
207-
? idleAlternateUpdateAvailableIcon
194+
? idleAlternateUpdateIcon
208195
: idleAlternateIcon,
209196
);
210197
} else {
211198
mb.tray.setImage(
212-
updateAvailableMenuItem.visible ? idleUpdateAvailableIcon : idleIcon,
199+
updateAvailableMenuItem.visible ? idleUpdateIcon : idleIcon,
213200
);
214201
}
215202
}
@@ -308,3 +295,7 @@ function resetApp() {
308295
mb.app.quit();
309296
}
310297
}
298+
299+
function getIconPath(iconName) {
300+
return path.resolve(__dirname, '../../assets/images', iconName);
301+
}

0 commit comments

Comments
 (0)