@@ -6,7 +6,7 @@ import { TeamManager } from './managers/team-manager.js';
66// Auth manager will be imported after Supabase is loaded
77import { PomodoroTimer } from './core/pomodoro-timer.js' ;
88import { NotificationUtils } from './utils/common-utils.js' ;
9- // Removed unused import: updateNotification
9+ import { UpdateNotification } from './components/update-notification.js' ;
1010
1111// Global application state
1212let timer = null ;
@@ -299,42 +299,42 @@ async function initializeEarlyTheme() {
299299
300300 // Helper function to check if Tauri is available and ready
301301 function isTauriReady ( ) {
302- return typeof window !== 'undefined' &&
303- window . __TAURI__ &&
304- window . __TAURI__ . core &&
305- typeof window . __TAURI__ . core . invoke === 'function' ;
302+ return typeof window !== 'undefined' &&
303+ window . __TAURI__ &&
304+ window . __TAURI__ . core &&
305+ typeof window . __TAURI__ . core . invoke === 'function' ;
306306 }
307307
308308 // Helper function to wait for Tauri to be ready (with timeout)
309309 function waitForTauri ( maxWaitTime = 2000 ) {
310310 return new Promise ( ( resolve ) => {
311311 const startTime = Date . now ( ) ;
312-
312+
313313 const checkTauri = ( ) => {
314314 if ( isTauriReady ( ) ) {
315315 resolve ( true ) ;
316316 return ;
317317 }
318-
318+
319319 if ( Date . now ( ) - startTime > maxWaitTime ) {
320320 resolve ( false ) ;
321321 return ;
322322 }
323-
323+
324324 setTimeout ( checkTauri , 50 ) ;
325325 } ;
326-
326+
327327 checkTauri ( ) ;
328328 } ) ;
329329 }
330330
331331 try {
332332 // Wait for Tauri to be ready before trying to load settings
333333 const tauriReady = await waitForTauri ( ) ;
334-
334+
335335 if ( tauriReady ) {
336336 console . log ( '🎨 Tauri is ready, loading theme from settings...' ) ;
337-
337+
338338 try {
339339 const { invoke } = window . __TAURI__ . core ;
340340 const savedSettings = await invoke ( 'load_settings' ) ;
@@ -1467,19 +1467,19 @@ async function initializeApplication() {
14671467 console . log ( '🚀 Application already fully initialized, skipping...' ) ;
14681468 return ;
14691469 }
1470-
1470+
14711471 // Prevent concurrent initialization attempts
14721472 if ( window . _appInitializing ) {
14731473 console . log ( '🚀 Application initialization already in progress, skipping...' ) ;
14741474 return ;
14751475 }
1476-
1476+
14771477 // Set initialization flag early to prevent race conditions
14781478 window . _appInitializing = true ;
1479-
1479+
14801480 try {
14811481 console . log ( '🚀 Initializing Presto application...' ) ;
1482-
1482+
14831483 // Show loading state
14841484 const loadingOverlay = document . createElement ( 'div' ) ;
14851485 loadingOverlay . id = 'app-loading' ;
@@ -1512,7 +1512,7 @@ async function initializeApplication() {
15121512 if ( stuckOverlay ) {
15131513 console . error ( '⚠️ Initialization timeout - removing loading overlay' ) ;
15141514 stuckOverlay . remove ( ) ;
1515-
1515+
15161516 // Show error message
15171517 NotificationUtils . showNotificationPing ( 'Initialization timed out. Please refresh! 🔄' , 'error' ) ;
15181518 }
@@ -1556,6 +1556,11 @@ async function initializeApplication() {
15561556 window . updateManager . loadPreferences ( ) ; // Carica le preferenze salvate se supportato
15571557 }
15581558
1559+ // Initialize Update Notification component
1560+ console . log ( '🔔 Initializing Update Notification...' ) ;
1561+ const updateNotification = new UpdateNotification ( ) ;
1562+ window . updateNotification = updateNotification ; // Make it globally available
1563+
15591564 // Skip first run authentication - proceed directly with guest mode
15601565 if ( authManager . isFirstRun ( ) ) {
15611566 console . log ( '👋 First run detected, proceeding as guest...' ) ;
@@ -1613,7 +1618,7 @@ async function initializeApplication() {
16131618
16141619 // Clear safety timeout
16151620 clearTimeout ( safetyTimeout ) ;
1616-
1621+
16171622 // Mark as fully initialized
16181623 window . _appFullyInitialized = true ;
16191624 window . _appInitializing = false ;
@@ -1629,21 +1634,21 @@ async function initializeApplication() {
16291634
16301635 } catch ( error ) {
16311636 console . error ( '❌ Failed to initialize application:' , error ) ;
1632-
1637+
16331638 // Clear safety timeout and remove loading overlay even on error
16341639 clearTimeout ( safetyTimeout ) ;
16351640 const loadingOverlayError = document . getElementById ( 'app-loading' ) ;
16361641 if ( loadingOverlayError ) {
16371642 loadingOverlayError . remove ( ) ;
16381643 }
1639-
1644+
16401645 // Show error notification
16411646 NotificationUtils . showNotificationPing ( 'Failed to initialize app. Please refresh! 🔄' , 'error' ) ;
1642-
1647+
16431648 // Reset initialization flags on error so user can retry
16441649 window . _appInitializing = false ;
16451650 window . _appFullyInitialized = false ;
1646-
1651+
16471652 // Show error screen instead of leaving user with blank screen
16481653 const errorScreen = document . createElement ( 'div' ) ;
16491654 errorScreen . id = 'app-error' ;
@@ -1891,9 +1896,10 @@ function setupUpdateManagement() {
18911896 }
18921897 } ) ;
18931898
1894- updateManager . on ( 'checkError' , ( ) => {
1899+ updateManager . on ( 'checkError' , ( event ) => {
18951900 if ( updateStatus ) {
1896- updateStatus . innerHTML = '<span class="status-text error">Check failed</span>' ;
1901+ const errorMessage = event ?. detail ?. message || 'Check failed' ;
1902+ updateStatus . innerHTML = `<span class="status-text error">${ errorMessage } </span>` ;
18971903 }
18981904 } ) ;
18991905
0 commit comments