@@ -2,7 +2,6 @@ import { createEffect, onCleanup, type Accessor } from 'solid-js';
22import { store } from './store' ;
33import { getTaskDotStatus , type TaskDotStatus } from './taskStatus' ;
44import { setActiveTask } from './navigation' ;
5- import { invoke } from '../lib/ipc' ;
65import { IPC } from '../../electron/ipc/channels' ;
76
87const DEBOUNCE_MS = 3_000 ;
@@ -34,12 +33,11 @@ export function startDesktopNotificationWatcher(windowFocused: Accessor<boolean>
3433 ready . length === 1
3534 ? `${ taskName ( taskIds [ 0 ] ) } is ready for review`
3635 : `${ ready . length } tasks ready for review` ;
37- invoke ( IPC . ShowNotification , {
36+ window . electron . ipcRenderer . send ( IPC . ShowNotification , {
3837 title : 'Task Ready' ,
3938 body,
40- threadId : 'pc-task-ready' ,
4139 taskIds,
42- } ) . catch ( console . warn ) ;
40+ } ) ;
4341 }
4442
4543 if ( waiting . length > 0 ) {
@@ -48,12 +46,11 @@ export function startDesktopNotificationWatcher(windowFocused: Accessor<boolean>
4846 waiting . length === 1
4947 ? `${ taskName ( taskIds [ 0 ] ) } needs your attention`
5048 : `${ waiting . length } tasks need your attention` ;
51- invoke ( IPC . ShowNotification , {
49+ window . electron . ipcRenderer . send ( IPC . ShowNotification , {
5250 title : 'Task Waiting' ,
5351 body,
54- threadId : 'pc-task-waiting' ,
5552 taskIds,
56- } ) . catch ( console . warn ) ;
53+ } ) ;
5754 }
5855 }
5956
@@ -62,6 +59,7 @@ export function startDesktopNotificationWatcher(windowFocused: Accessor<boolean>
6259 }
6360
6461 function scheduleBatch ( notification : PendingNotification ) : void {
62+ if ( ! store . desktopNotificationsEnabled ) return ;
6563 pending . push ( notification ) ;
6664 if ( debounceTimer === undefined ) {
6765 debounceTimer = setTimeout ( flushNotifications , DEBOUNCE_MS ) ;
@@ -111,9 +109,10 @@ export function startDesktopNotificationWatcher(windowFocused: Accessor<boolean>
111109 const offNotificationClicked = window . electron . ipcRenderer . on (
112110 IPC . NotificationClicked ,
113111 ( data : unknown ) => {
114- const msg = data as { taskIds : string [ ] } ;
115- if ( msg . taskIds ?. length ) {
116- setActiveTask ( msg . taskIds [ 0 ] ) ;
112+ const msg = data as Record < string , unknown > ;
113+ const taskIds = Array . isArray ( msg ?. taskIds ) ? ( msg . taskIds as string [ ] ) : [ ] ;
114+ if ( taskIds . length ) {
115+ setActiveTask ( taskIds [ 0 ] ) ;
117116 }
118117 } ,
119118 ) ;
0 commit comments