Skip to content

Commit 93286dd

Browse files
authored
Merge pull request #38 from murdercode/hide-status-bar
Hide status bar
2 parents 54cf55c + e574103 commit 93286dd

File tree

4 files changed

+181
-72
lines changed

4 files changed

+181
-72
lines changed

src/components/update-notification.js

Lines changed: 28 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ export class UpdateNotification {
3535
if (getUpdateManager()) {
3636
console.log('✅ [UpdateNotification] UpdateManager trovato, bind eventi notifica');
3737
this.bindEvents();
38-
38+
3939
// RIMOSSO: Il controllo dello stato iniziale può causare problemi
4040
// L'updateManager dovrebbe emettere gli eventi corretti al momento giusto
4141
} else {
@@ -357,10 +357,23 @@ export class UpdateNotification {
357357
*/
358358
bindButtonEvents() {
359359
const buttons = this.container.querySelectorAll('[data-action]');
360+
console.log('🔔 [UpdateNotification] Trovati', buttons.length, 'pulsanti con data-action');
360361
buttons.forEach(button => {
362+
console.log('🔔 [UpdateNotification] Binding evento per pulsante:', button.dataset.action);
361363
button.addEventListener('click', (e) => {
362-
const action = e.target.dataset.action;
363-
this.handleAction(action);
364+
// Trova il pulsante con data-action, anche se si clicca su un elemento figlio (come l'icona SVG)
365+
let target = e.target;
366+
while (target && !target.dataset.action) {
367+
target = target.parentElement;
368+
}
369+
370+
const action = target ? target.dataset.action : null;
371+
console.log('🔔 [UpdateNotification] Target trovato:', target, 'Action:', action);
372+
if (action) {
373+
this.handleAction(action);
374+
} else {
375+
console.warn('🔔 [UpdateNotification] Nessuna azione trovata per questo click');
376+
}
364377
});
365378
});
366379
}
@@ -369,6 +382,7 @@ export class UpdateNotification {
369382
* Handles button actions
370383
*/
371384
handleAction(action) {
385+
console.log('🔔 [UpdateNotification] Azione pulsante:', action);
372386
switch (action) {
373387
case 'download':
374388
this.startDownload();
@@ -538,14 +552,15 @@ export class UpdateNotification {
538552
}
539553

540554
// Verifica se siamo in modalità sviluppo senza test mode
541-
const updateManager = getUpdateManager();
542-
if (updateManager && updateManager.isDevelopmentMode && updateManager.isDevelopmentMode()) {
543-
const hasTestMode = localStorage.getItem('presto_force_update_test') === 'true';
544-
if (!hasTestMode) {
545-
console.log('🔍 [UpdateNotification] Modalità sviluppo senza test mode - non mostro notifica');
546-
return;
547-
}
548-
}
555+
// RIMOSSO: Ora permettiamo la notifica anche in modalità sviluppo per GitHub releases
556+
// const updateManager = getUpdateManager();
557+
// if (updateManager && updateManager.isDevelopmentMode && updateManager.isDevelopmentMode()) {
558+
// const hasTestMode = localStorage.getItem('presto_force_update_test') === 'true';
559+
// if (!hasTestMode) {
560+
// console.log('🔍 [UpdateNotification] Modalità sviluppo senza test mode - non mostro notifica');
561+
// return;
562+
// }
563+
// }
549564

550565
// Don't show if this version has been skipped
551566
if (this.isVersionSkipped(updateInfo.version)) {
@@ -659,5 +674,5 @@ export class UpdateNotification {
659674
}
660675
}
661676

662-
// Export singleton instance
663-
export const updateNotification = new UpdateNotification();
677+
// Export the class, not an instance - let main.js handle initialization
678+
// export const updateNotification = new UpdateNotification();

src/main.js

Lines changed: 29 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { TeamManager } from './managers/team-manager.js';
66
// Auth manager will be imported after Supabase is loaded
77
import { PomodoroTimer } from './core/pomodoro-timer.js';
88
import { NotificationUtils } from './utils/common-utils.js';
9-
// Removed unused import: updateNotification
9+
import { UpdateNotification } from './components/update-notification.js';
1010

1111
// Global application state
1212
let 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

Comments
 (0)