experiments in a post-browser web
10
fork

Configure Feed

Select the types of activity you want to include in your feed.

switcher fix and load urls pending from being passed by OS before app ready

+37 -4
+37 -4
index.js
··· 463 463 const onReady = async () => { 464 464 console.log('onReady'); 465 465 466 + // Hide dock early to prevent flash in app switcher 467 + // Will be shown later if showInDockAndSwitcher pref is true 468 + if (app.dock && !DEBUG) { 469 + console.log('hiding dock early (non-debug mode)'); 470 + app.dock.hide(); 471 + } 472 + 466 473 // Initialize datastore with SQLite persistence 467 474 await initDatastore(profileDataPath); 468 475 ··· 552 559 // cache all prefs 553 560 _prefs = msg.prefs; 554 561 555 - // show/hide in dock and tab switcher 556 - if (DEBUG == false || (app.dock && msg.prefs.showInDockAndSwitcher == false)) { 557 - console.log('hiding dock'); 558 - app.dock.hide(); 562 + // show/hide in dock and tab switcher based on preference 563 + if (app.dock) { 564 + if (msg.prefs.showInDockAndSwitcher === true) { 565 + console.log('showing dock (pref enabled)'); 566 + app.dock.show(); 567 + } else { 568 + console.log('hiding dock (pref disabled)'); 569 + app.dock.hide(); 570 + } 559 571 } 560 572 561 573 // initialize system tray ··· 715 727 // Register default quit shortcut - will be updated when prefs arrive 716 728 _quitShortcut = strings.defaults.quitShortcut; 717 729 registerShortcut(_quitShortcut, onQuit); 730 + 731 + // Mark app as ready and process any URLs that arrived during startup 732 + _appReady = true; 733 + processPendingUrls(); 718 734 }; 719 735 720 736 // ***** External URL Handler ***** 721 737 738 + // Track if app is ready to handle URLs 739 + let _appReady = false; 740 + let _pendingUrls = []; 741 + 722 742 // Handle URLs opened from external apps (e.g., when Peek is default browser) 723 743 const handleExternalUrl = (url, sourceId = 'os') => { 724 744 console.log('External URL received:', url, 'from:', sourceId); 725 745 746 + if (!_appReady) { 747 + _pendingUrls.push({ url, sourceId }); 748 + return; 749 + } 750 + 726 751 // Note: Using trackingSource/trackingSourceId because preload.js overwrites msg.source 727 752 pubsub.publish(systemAddress, scopes.GLOBAL, 'external:open-url', { 728 753 url, ··· 730 755 trackingSourceId: sourceId, 731 756 timestamp: Date.now() 732 757 }); 758 + }; 759 + 760 + // Process any URLs that arrived before app was ready 761 + const processPendingUrls = () => { 762 + _pendingUrls.forEach(({ url, sourceId }) => { 763 + handleExternalUrl(url, sourceId); 764 + }); 765 + _pendingUrls = []; 733 766 }; 734 767 735 768 // macOS: handle open-url event (must be registered before app.whenReady)