From 6336484c36a0b546661bc41801d220e1ed8312ba Mon Sep 17 00:00:00 2001 From: Adam Setch Date: Sun, 1 Sep 2024 08:39:20 -0400 Subject: [PATCH 1/3] fix: alternate idle images for linux Signed-off-by: Adam Setch --- assets/images/tray-idle-white-update.png | Bin 0 -> 595 bytes assets/images/tray-idle-white-update@2x.png | Bin 0 -> 1338 bytes assets/images/tray-idle-white.png | Bin 0 -> 490 bytes assets/images/tray-idle-white@2x.png | Bin 0 -> 996 bytes assets/images/tray-idleTemplate.png | Bin 503 -> 1134 bytes src/electron/main.js | 20 +++++++++++++++++--- 6 files changed, 17 insertions(+), 3 deletions(-) create mode 100644 assets/images/tray-idle-white-update.png create mode 100644 assets/images/tray-idle-white-update@2x.png create mode 100644 assets/images/tray-idle-white.png create mode 100644 assets/images/tray-idle-white@2x.png diff --git a/assets/images/tray-idle-white-update.png b/assets/images/tray-idle-white-update.png new file mode 100644 index 0000000000000000000000000000000000000000..5b040ca9655edc5982e358ad53e401ba40f61c87 GIT binary patch literal 595 zcmV-Z0<8UsP) zO(-r=7{?9a=ChCm`B+M>jVKFA=yprVik%G`*;u&J&B8~LY@`&68)YLaB_G*ZNZGKm zAdwBCNXX^&``4jk-jA7Cyk+XwnKSb||NlJCIdhzZIA2bj^%K6AK`0bTq~gzyavbN? zs{@`DAew^6PiTT7$Tp%O#v_=)=q{R3OasI#NgRe|NVC7*2);3n2ux%cc11Nn{1?&x zpunRIbG+}tKxY075U(I|6AG;i_4^5Ip=0J~0;^%8R( z$s|$*V@5>rD!)!W=F5L@zXpvip$F#L4E@ACyG^_dw5Sav?ivFve7zCT-v0wjyno<5 zL-}tzSO@hv1F;ih7|g&V>4?~de9J^XnigG0g4)sv z#h{-o2j*c2<4e1WSVu(*feVo9E}Qv1l)?aLp>^FrD+W7$4P;&g<4_0MruMbLq#g8M zbc5DOYxm{yb6lsAQ3KllC7`($eit^)7A_{>w#Mw| zrL~{iKc+8WUwg3cfxZVC&cKL;P`lke0NV}(pV`vp#qL(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ty`M;qWz$W>2I6WL#m=y89#-d7L8= gK>~^X34Slq4_e!O8NNO(IsgCw07*qoM6N<$g8o9$*8l(j literal 0 HcmV?d00001 diff --git a/assets/images/tray-idle-white@2x.png b/assets/images/tray-idle-white@2x.png new file mode 100644 index 0000000000000000000000000000000000000000..d8f5bf107e3570f0bbd14deb7caf054f42d61f23 GIT binary patch literal 996 zcmV$k4}5Oz4!XQy$_w*U#<2z-(Ks#{{L_7y}z}0rliP6rpWo1 zqyqkT1=9+o6^OY4=_O=Zz-%_#llj4(_2uYas1D{HVh=KzjQn;UiB$m7<6yBETZok@ z8C}P31tOj({X4nE769?Fpl-+JIg+?T++;-ja*1~q0P$`l+=*?#y0|3Iid;zMEBG2yb5y?Js{*YIx#~j}o{5v51*_CvD zoQ;4Z1g?xodYtncA@?>3avBVk09JnhU{dn1$7LhL>orM}^wA1fP15F&#O;umUHG35 zt$?#I3)*Sr1{{firzZAPPlQd!`Uj}{#C!|!w_Ma~1<2(yC?G)_$(Q)gL0qs;VVcT( z!>=5i+qNPi1$fVXS>>SXzm~*J1_3q9b(#+$_>6NCz74m2p9^OtWMCVBH0NJtUYKi3eHGx;FjnfE_uJe1yB~(wsMuUJl z=5}d``21?X+^>m^6d)kn2QN9uUSJxnBwJ<>Ai^(VR=BCjj>q^QGXv4-=skunv&DAwbp}8C9JI-epWGWg5~$ z4UD>>wF07UWFeq#CA`)|p7}#U7DYCNo5b~!nd5$MBt)wW4}{?e*T>mctO*27sqE)zF)1;2M- z6D_lU#s46-1@a#(WB4H<-Mr+=cWPD~1uyi3>=QoCYfupjo9t`lJ;oq9LW3f7a|Qt(3-gqV^*L>(uCLYK<&v-_y^f%Jlu3~`1+ z$241p{t1&Uzajsif52oY-2x#)?vouyrM0vioqNu`=iR5!`=Xxo;|;J zp8){zwt6p@a zSkY7?xkP?#YmVI|n_XN1Cb|>xztz4?4oke^PG^;~ zQ25J<#?5dX#(R@D#VPrm>lDa^!K7-fg*DGFF=z1>t(r-f Pe}q;0b$0DfPmW3tyCKb8 delta 60 zcmaFI@tt{siUwnGkh>GZx^prw85kH`QX@Rme0>?TfNTy1#`a7G79fieh@~dB>#;mC MEnU0$D^n#S0P|N5&;S4c diff --git a/src/electron/main.js b/src/electron/main.js index 9bbb7bd99..11856b6f8 100644 --- a/src/electron/main.js +++ b/src/electron/main.js @@ -21,9 +21,15 @@ log.initialize(); const idleIcon = path.resolve( `${__dirname}/../../assets/images/tray-idleTemplate.png`, ); +const idleAlternateIcon = path.resolve( + `${__dirname}/../../assets/images/tray-idle-white.png`, +); const idleUpdateAvailableIcon = path.resolve( `${__dirname}/../../assets/images/tray-idle-update.png`, ); +const idleAlternateUpdateAvailableIcon = path.resolve( + `${__dirname}/../../assets/images/tray-idle-white-update.png`, +); const activeIcon = path.resolve( `${__dirname}/../../assets/images/tray-active.png`, ); @@ -189,9 +195,17 @@ app.whenReady().then(async () => { ipc.on('gitify:icon-idle', () => { if (!mb.tray.isDestroyed()) { - mb.tray.setImage( - updateAvailableMenuItem.visible ? idleUpdateAvailableIcon : idleIcon, - ); + if (process.platform === 'darwin' || process.platform === 'win32') { + mb.tray.setImage( + updateAvailableMenuItem.visible ? idleUpdateAvailableIcon : idleIcon, + ); + } else { + mb.tray.setImage( + updateAvailableMenuItem.visible + ? idleAlternateUpdateAvailableIcon + : idleAlternateIcon, + ); + } } }); From 03656f15bf87628f6a0747bd4ddc51e6a9f48410 Mon Sep 17 00:00:00 2001 From: Adam Setch Date: Sun, 1 Sep 2024 10:40:53 -0400 Subject: [PATCH 2/3] fix: alternate idle images for linux Signed-off-by: Adam Setch --- src/electron/main.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/electron/main.js b/src/electron/main.js index 11856b6f8..bedcc1adb 100644 --- a/src/electron/main.js +++ b/src/electron/main.js @@ -195,16 +195,16 @@ app.whenReady().then(async () => { ipc.on('gitify:icon-idle', () => { if (!mb.tray.isDestroyed()) { - if (process.platform === 'darwin' || process.platform === 'win32') { - mb.tray.setImage( - updateAvailableMenuItem.visible ? idleUpdateAvailableIcon : idleIcon, - ); - } else { + if (process.platform === 'linux') { mb.tray.setImage( updateAvailableMenuItem.visible ? idleAlternateUpdateAvailableIcon : idleAlternateIcon, ); + } else { + mb.tray.setImage( + updateAvailableMenuItem.visible ? idleUpdateAvailableIcon : idleIcon, + ); } } }); From 57d3a4e98d63f5159b0ccf3e2c097a5ac066fe26 Mon Sep 17 00:00:00 2001 From: Adam Setch Date: Wed, 4 Sep 2024 07:31:33 -0400 Subject: [PATCH 3/3] fix: use user setting to control alternate idle icon Signed-off-by: Adam Setch --- src/__mocks__/state-mocks.ts | 1 + .../settings/SystemSettings.test.tsx | 25 +++++++++++ src/components/settings/SystemSettings.tsx | 15 +++++++ src/context/App.test.tsx | 36 +--------------- src/context/App.tsx | 6 +++ src/electron/main.js | 8 +++- .../__snapshots__/Settings.test.tsx.snap | 43 +++++++++++++++++++ src/types.ts | 9 ++-- src/utils/comms.test.ts | 10 +++++ src/utils/comms.ts | 4 ++ 10 files changed, 118 insertions(+), 39 deletions(-) diff --git a/src/__mocks__/state-mocks.ts b/src/__mocks__/state-mocks.ts index 12b3f638e..1abcd36f5 100644 --- a/src/__mocks__/state-mocks.ts +++ b/src/__mocks__/state-mocks.ts @@ -96,6 +96,7 @@ const mockSystemSettings = { showNotificationsCountInTray: false, showNotifications: true, playSound: true, + useAlternateIdleIcon: false, openAtStartup: false, }; diff --git a/src/components/settings/SystemSettings.test.tsx b/src/components/settings/SystemSettings.test.tsx index f424b79c2..f11f019f9 100644 --- a/src/components/settings/SystemSettings.test.tsx +++ b/src/components/settings/SystemSettings.test.tsx @@ -137,6 +137,31 @@ describe('routes/components/settings/SystemSettings.tsx', () => { expect(updateSetting).toHaveBeenCalledWith('playSound', false); }); + it('should toggle the useAlternateIdleIcon checkbox', async () => { + await act(async () => { + render( + + + + + , + ); + }); + + fireEvent.click(screen.getByLabelText('Use alternate idle icon'), { + target: { checked: true }, + }); + + expect(updateSetting).toHaveBeenCalledTimes(1); + expect(updateSetting).toHaveBeenCalledWith('useAlternateIdleIcon', false); + }); + it('should toggle the openAtStartup checkbox', async () => { await act(async () => { render( diff --git a/src/components/settings/SystemSettings.tsx b/src/components/settings/SystemSettings.tsx index 1d87ad3f7..22bfec3e0 100644 --- a/src/components/settings/SystemSettings.tsx +++ b/src/components/settings/SystemSettings.tsx @@ -67,6 +67,21 @@ export const SystemSettings: FC = () => { checked={settings.playSound} onChange={(evt) => updateSetting('playSound', evt.target.checked)} /> + + updateSetting('useAlternateIdleIcon', evt.target.checked) + } + tooltip={ +
+ Use a white Gitify logo (instead of the default black logo) when all + notifications are read. Particularly useful for devices which have a + dark-themed menubar or taskbar. +
+ } + /> {!isLinux() && ( { user: null, } as AuthState, settings: { + ...defaultSettings, participating: true, - playSound: true, - showNotifications: true, - hideBots: false, - showNotificationsCountInTray: false, - openAtStartup: false, - theme: 'SYSTEM', - detailedNotifications: true, - markAsDoneOnOpen: false, - showAccountHeader: false, - delayNotificationState: false, - showPills: true, - showNumber: true, - keyboardShortcut: true, - groupBy: 'REPOSITORY', - filterReasons: [], - zoomPercentage: 100, - openLinks: 'FOREGROUND', } as SettingsState, }); }); @@ -402,24 +386,8 @@ describe('context/App.tsx', () => { user: null, } as AuthState, settings: { - participating: false, - playSound: true, - showNotifications: true, - hideBots: false, - showNotificationsCountInTray: false, + ...defaultSettings, openAtStartup: true, - theme: 'SYSTEM', - detailedNotifications: true, - markAsDoneOnOpen: false, - showAccountHeader: false, - delayNotificationState: false, - showPills: true, - showNumber: true, - keyboardShortcut: true, - groupBy: 'REPOSITORY', - filterReasons: [], - zoomPercentage: 100, - openLinks: 'FOREGROUND', } as SettingsState, }); }); diff --git a/src/context/App.tsx b/src/context/App.tsx index eb93a8e91..f727b77d2 100644 --- a/src/context/App.tsx +++ b/src/context/App.tsx @@ -37,6 +37,7 @@ import { removeAccount, } from '../utils/auth/utils'; import { + setAlternateIdleIcon, setAutoLaunch, setKeyboardShortcut, updateTrayTitle, @@ -76,6 +77,7 @@ const defaultSystemSettings = { showNotificationsCountInTray: false, showNotifications: true, playSound: true, + useAlternateIdleIcon: false, openAtStartup: false, }; @@ -195,6 +197,9 @@ export const AppProvider = ({ children }: { children: ReactNode }) => { if (name === 'openAtStartup') { setAutoLaunch(value as boolean); } + if (name === 'useAlternateIdleIcon') { + setAlternateIdleIcon(value as boolean); + } const newSettings = { ...settings, [name]: value }; setSettings(newSettings); @@ -270,6 +275,7 @@ export const AppProvider = ({ children }: { children: ReactNode }) => { if (existing.settings) { setKeyboardShortcut(existing.settings.keyboardShortcut); + setAlternateIdleIcon(existing.settings.useAlternateIdleIcon); setSettings({ ...defaultSettings, ...existing.settings }); webFrame.setZoomLevel( zoomPercentageToLevel(existing.settings.zoomPercentage), diff --git a/src/electron/main.js b/src/electron/main.js index bedcc1adb..bc7637dbe 100644 --- a/src/electron/main.js +++ b/src/electron/main.js @@ -120,6 +120,8 @@ const mb = menubar({ showDockIcon: false, }); +let shouldUseAlternateIdleIcon = false; + app.whenReady().then(async () => { await onFirstRunMaybe(); @@ -183,6 +185,10 @@ app.whenReady().then(async () => { ipc.on('gitify:quit', () => mb.app.quit()); + ipc.on('gitify:use-alternate-idle-icon', (_, useAlternateIdleIcon) => { + shouldUseAlternateIdleIcon = useAlternateIdleIcon; + }); + ipc.on('gitify:icon-active', () => { if (!mb.tray.isDestroyed()) { mb.tray.setImage( @@ -195,7 +201,7 @@ app.whenReady().then(async () => { ipc.on('gitify:icon-idle', () => { if (!mb.tray.isDestroyed()) { - if (process.platform === 'linux') { + if (shouldUseAlternateIdleIcon) { mb.tray.setImage( updateAvailableMenuItem.visible ? idleAlternateUpdateAvailableIcon diff --git a/src/routes/__snapshots__/Settings.test.tsx.snap b/src/routes/__snapshots__/Settings.test.tsx.snap index 74818bec6..ad0920933 100644 --- a/src/routes/__snapshots__/Settings.test.tsx.snap +++ b/src/routes/__snapshots__/Settings.test.tsx.snap @@ -752,6 +752,49 @@ exports[`routes/Settings.tsx should render itself & its children 1`] = ` +
+
+ +
+ +
+
+
diff --git a/src/types.ts b/src/types.ts index d21ffb95f..80ceda8f0 100644 --- a/src/types.ts +++ b/src/types.ts @@ -75,19 +75,20 @@ interface AppearanceSettingsState { } interface NotificationSettingsState { + groupBy: GroupBy; participating: boolean; - showNotifications: boolean; markAsDoneOnOpen: boolean; delayNotificationState: boolean; - groupBy: GroupBy; } interface SystemSettingsState { openLinks: OpenPreference; + keyboardShortcut: boolean; + showNotificationsCountInTray: boolean; + showNotifications: boolean; + useAlternateIdleIcon: boolean; playSound: boolean; openAtStartup: boolean; - showNotificationsCountInTray: boolean; - keyboardShortcut: boolean; } interface FilterSettingsState { diff --git a/src/utils/comms.test.ts b/src/utils/comms.test.ts index e78779d14..a71bc5a9c 100644 --- a/src/utils/comms.test.ts +++ b/src/utils/comms.test.ts @@ -6,6 +6,7 @@ import { hideWindow, openExternalLink, quitApp, + setAlternateIdleIcon, setAutoLaunch, showWindow, updateTrayIcon, @@ -104,4 +105,13 @@ describe('utils/comms.ts', () => { openAtLogin: false, }); }); + + it('should setAlternateIdleIcon', () => { + setAlternateIdleIcon(true); + + expect(ipcRenderer.send).toHaveBeenCalledWith( + 'gitify:use-alternate-idle-icon', + true, + ); + }); }); diff --git a/src/utils/comms.ts b/src/utils/comms.ts index 0a11fa0c3..3abe897f2 100644 --- a/src/utils/comms.ts +++ b/src/utils/comms.ts @@ -42,6 +42,10 @@ export function setAutoLaunch(value: boolean): void { }); } +export function setAlternateIdleIcon(value: boolean): void { + ipcRenderer.send('gitify:use-alternate-idle-icon', value); +} + export function setKeyboardShortcut(keyboardShortcut: boolean): void { ipcRenderer.send('gitify:update-keyboard-shortcut', { enabled: keyboardShortcut,