Skip to content

Commit 7ea7570

Browse files
5.1.5
1 parent c6251d0 commit 7ea7570

2 files changed

Lines changed: 34 additions & 42 deletions

File tree

minimal.js

Lines changed: 32 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -204,52 +204,44 @@ app.whenReady().then(async () => {
204204
]);
205205
tray.setToolTip('Pinokio');
206206
tray.setContextMenu(contextMenu);
207-
const announceTray = () => {
208-
if (process.platform === 'darwin') {
209-
try {
210-
tray.setHighlightMode('always')
211-
tray.setTitle('Pinokio running')
212-
setTimeout(() => tray.setHighlightMode('selection'), 4000)
213-
setTimeout(() => tray.popUpContextMenu(contextMenu), 150)
214-
} catch (err) {
215-
console.warn('Failed to set tray highlight/title', err)
216-
}
217-
return
207+
const showNotification = (options = {}) => {
208+
try {
209+
new Notification({
210+
title: 'Pinokio',
211+
body: 'Running in background',
212+
...options
213+
}).show()
214+
} catch (err) {
215+
console.warn('Failed to show background notification', err)
218216
}
219-
220-
if (process.platform === 'win32') {
221-
try {
222-
app.setAppUserModelId('Pinokio')
223-
} catch (err) {
224-
console.warn('Failed to set AppUserModelID', err)
225-
}
226-
227-
let notified = false
228-
if (Notification && typeof Notification.isSupported === 'function' && Notification.isSupported()) {
217+
}
218+
const announceTray = () => {
219+
const platformHandlers = {
220+
darwin: () => {
229221
try {
230-
new Notification({
231-
title: 'Pinokio',
232-
body: 'Running in background',
233-
icon: iconPath
234-
}).show()
235-
notified = true
222+
tray.setHighlightMode('always')
223+
tray.setTitle('Pinokio running')
224+
setTimeout(() => tray.setHighlightMode('selection'), 4000)
225+
setTimeout(() => tray.popUpContextMenu(contextMenu), 150)
236226
} catch (err) {
237-
console.warn('Failed to show background notification (toast)', err)
227+
console.warn('Failed to signal tray/notification on macOS', err)
238228
}
239-
}
240-
if (!notified && typeof tray.displayBalloon === 'function') {
241-
tray.displayBalloon({ title: 'Pinokio', content: 'Running in background', icon: iconPath })
242-
}
243-
return
244-
}
245-
246-
if (Notification && typeof Notification.isSupported === 'function' && Notification.isSupported()) {
247-
try {
248-
new Notification({ title: 'Pinokio', body: 'Running in background' }).show()
249-
} catch (err) {
250-
console.warn('Failed to show background notification', err)
229+
showNotification()
230+
},
231+
win32: () => {
232+
try {
233+
app.setAppUserModelId('Pinokio')
234+
} catch (err) {
235+
console.warn('Failed to set AppUserModelID', err)
236+
}
237+
showNotification({ icon: iconPath })
238+
},
239+
default: () => {
240+
showNotification()
251241
}
252242
}
243+
const handler = platformHandlers[process.platform] || platformHandlers.default
244+
handler()
253245
}
254246
announceTray()
255247
tray.on('click', () => {

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "Pinokio",
33
"private": true,
4-
"version": "5.1.4",
4+
"version": "5.1.5",
55
"homepage": "https://pinokio.co",
66
"description": "pinokio",
77
"main": "main.js",
@@ -144,7 +144,7 @@
144144
"electron-store": "^8.1.0",
145145
"electron-updater": "^6.6.2",
146146
"electron-window-state": "^5.0.3",
147-
"pinokiod": "^5.1.4"
147+
"pinokiod": "^5.1.5"
148148
},
149149
"devDependencies": {
150150
"@electron/rebuild": "3.2.10",

0 commit comments

Comments
 (0)