@@ -30,6 +30,9 @@ function UpdateNotification() {
3030 useEffect ( ( ) => {
3131 mounted . current = true ;
3232
33+ // Add logging to confirm listener setup
34+ log . info ( '[UpdateNotification] Setting up event listeners' ) ;
35+
3336 // Get current version
3437 window . electron . ipcRenderer . invoke ( 'get-app-version' ) . then ( ( version ) => {
3538 if ( mounted . current ) {
@@ -63,6 +66,14 @@ function UpdateNotification() {
6366
6467 // Listen for update status changes
6568 const handleUpdateStatus = ( _event : any , data : any ) => {
69+ log . info ( `[UpdateNotification] Received update status: ${ data . status } ` , {
70+ info : data . info ? { version : data . info . version } : undefined ,
71+ error : data . error ,
72+ mounted : mounted . current ,
73+ userDismissed,
74+ currentUpdateVersion : updateStatus . info ?. version
75+ } ) ;
76+
6677 if ( ! mounted . current ) return ;
6778
6879 // Clear any existing hide timeout
@@ -74,6 +85,7 @@ function UpdateNotification() {
7485 // Don't show notification if user dismissed and it's the same update
7586 if ( userDismissed && data . status === 'available' &&
7687 updateStatus . info ?. version === data . info ?. version ) {
88+ log . info ( '[UpdateNotification] Skipping notification - user dismissed this version' ) ;
7789 return ;
7890 }
7991
@@ -84,8 +96,12 @@ function UpdateNotification() {
8496 progress : data . progress
8597 } ) ;
8698
87- // Show notification for all statuses except idle
88- if ( data . status !== 'idle' ) {
99+ // Always show notification for important statuses
100+ if ( data . status === 'available' || data . status === 'downloading' ||
101+ data . status === 'downloaded' || data . status === 'error' ) {
102+ log . info ( `[UpdateNotification] Showing notification for status: ${ data . status } ` ) ;
103+ setShowNotification ( true ) ;
104+ } else if ( data . status !== 'idle' ) {
89105 setShowNotification ( true ) ;
90106
91107 // Auto-hide "not-available" after 3 seconds
@@ -100,32 +116,85 @@ function UpdateNotification() {
100116 } ;
101117
102118 // Listen for menu-triggered update checks
103- const handleCheckForUpdatesMenu = ( ) => {
119+ const handleCheckForUpdatesMenu = async ( ) => {
104120 if ( ! mounted . current ) return ;
105121
122+ log . info ( 'Received check-for-updates-menu event' ) ;
106123 setUserDismissed ( false ) ;
107124
125+ // Clear any existing hide timeout
126+ if ( hideTimeoutRef . current ) {
127+ clearTimeout ( hideTimeoutRef . current ) ;
128+ hideTimeoutRef . current = null ;
129+ }
130+
108131 // Show checking status immediately
109132 setUpdateStatus ( { status : 'checking' } ) ;
110133 setShowNotification ( true ) ;
111134
112- // Then invoke the check (status will be updated via 'update-status' event)
113- window . electron . ipcRenderer . invoke ( 'check-for-updates' ) ;
135+ // Actually invoke the check-for-updates-menu handler
136+ try {
137+ const result = await window . electron . ipcRenderer . invoke ( 'check-for-updates-menu' ) ;
138+ log . info ( '[UpdateNotification] check-for-updates-menu result:' , result ) ;
139+
140+ // Handle the result directly since IPC events aren't working
141+ if ( result . success && result . updateInfo ) {
142+ // Update available
143+ setUpdateStatus ( {
144+ status : 'available' ,
145+ info : {
146+ version : result . updateInfo . version ,
147+ releaseNotes : result . updateInfo . releaseNotes ,
148+ releaseDate : result . updateInfo . releaseDate
149+ }
150+ } ) ;
151+ setShowNotification ( true ) ;
152+ log . info ( `[UpdateNotification] Showing notification for available update: ${ result . updateInfo . version } ` ) ;
153+ } else if ( result . success && ! result . updateInfo ) {
154+ // No update available
155+ setUpdateStatus ( { status : 'not-available' } ) ;
156+ setShowNotification ( true ) ;
157+ // Auto-hide after 3 seconds
158+ hideTimeoutRef . current = setTimeout ( ( ) => {
159+ if ( mounted . current ) {
160+ setShowNotification ( false ) ;
161+ }
162+ } , 3000 ) ;
163+ } else {
164+ // Error
165+ setUpdateStatus ( { status : 'error' , error : result . error || 'Unknown error' } ) ;
166+ setShowNotification ( true ) ;
167+ }
168+ } catch ( error ) {
169+ log . error ( 'Failed to check for updates:' , error ) ;
170+ setUpdateStatus ( { status : 'error' , error : error instanceof Error ? error . message : 'Unknown error' } ) ;
171+ setShowNotification ( true ) ;
172+ }
173+ } ;
174+
175+ // Test listener to verify IPC communication
176+ const testHandler = ( data : any ) => {
177+ log . info ( '[UpdateNotification] TEST: Received any update-status event:' , data ) ;
114178 } ;
115179
116180 // Use the existing IPC pattern
181+ log . info ( '[UpdateNotification] Adding update-status listener' ) ;
117182 window . electron . ipcRenderer . on ( 'update-status' , handleUpdateStatus ) ;
183+ window . electron . ipcRenderer . on ( 'update-status' , testHandler ) ;
184+ log . info ( '[UpdateNotification] Adding check-for-updates-menu listener' ) ;
118185 window . electron . ipcRenderer . on ( 'check-for-updates-menu' , handleCheckForUpdatesMenu ) ;
119186
120187 return ( ) => {
121188 mounted . current = false ;
122189 if ( hideTimeoutRef . current ) {
123190 clearTimeout ( hideTimeoutRef . current ) ;
124191 }
192+ log . info ( '[UpdateNotification] Removing listeners' ) ;
125193 window . electron . ipcRenderer . removeListener ( 'update-status' , handleUpdateStatus ) ;
194+ window . electron . ipcRenderer . removeListener ( 'update-status' , testHandler ) ;
126195 window . electron . ipcRenderer . removeListener ( 'check-for-updates-menu' , handleCheckForUpdatesMenu ) ;
127196 } ;
128- } , [ userDismissed , updateStatus . info ?. version ] ) ;
197+ } , [ ] ) ;
129198
130199 const handleDownload = async ( ) => {
131200 const result = await window . electron . ipcRenderer . invoke ( 'download-update' ) ;
0 commit comments