diff --git a/app/assets/javascripts/app.tsx b/app/assets/javascripts/app.tsx index b8dbd9e2705..2b9151304a6 100644 --- a/app/assets/javascripts/app.tsx +++ b/app/assets/javascripts/app.tsx @@ -59,12 +59,22 @@ const startApplication: StartApplication = async function startApplication( }); } - window.addEventListener('DOMContentLoaded', () => { + const renderApp = () => { render( , document.body.appendChild(document.createElement('div')) ); - }); + }; + + const domReady = + document.readyState === 'complete' || document.readyState === 'interactive'; + if (domReady) { + renderApp(); + } else { + window.addEventListener('DOMContentLoaded', () => { + renderApp(); + }); + } }; if (IsWebPlatform) { diff --git a/app/assets/javascripts/services/desktopManager.ts b/app/assets/javascripts/services/desktopManager.ts index 55955298ab3..3b232a27e1c 100644 --- a/app/assets/javascripts/services/desktopManager.ts +++ b/app/assets/javascripts/services/desktopManager.ts @@ -15,12 +15,25 @@ import { WebAppEvent, WebApplication } from '@/ui_models/application'; import { isDesktopApplication } from '@/utils'; import { Bridge } from './bridge'; +export interface ElectronDesktopCallbacks { + desktop_updateAvailable(): void; + desktop_windowGainedFocus(): void; + desktop_windowLostFocus(): void; + desktop_onComponentInstallationComplete( + componentData: any, + error: any + ): Promise; + desktop_requestBackupFile(): Promise; + desktop_didBeginBackup(): void; + desktop_didFinishBackup(success: boolean): void; +} + /** * An interface used by the Desktop application to interact with SN */ export class DesktopManager extends ApplicationService - implements DesktopManagerInterface + implements DesktopManagerInterface, ElectronDesktopCallbacks { updateObservers: { callback: (component: SNComponent) => void; @@ -115,6 +128,10 @@ export class DesktopManager } } + desktop_updateAvailable(): void { + this.webApplication.notifyWebEvent(WebAppEvent.NewUpdateAvailable); + } + desktop_windowGainedFocus(): void { this.webApplication.notifyWebEvent(WebAppEvent.DesktopWindowGainedFocus); } @@ -152,7 +169,7 @@ export class DesktopManager } } - async desktop_requestBackupFile() { + async desktop_requestBackupFile(): Promise { const data = await this.application.createBackupFile( this.application.hasProtectionSources() ? EncryptionIntent.FileEncrypted diff --git a/app/assets/javascripts/ui_models/application_group.ts b/app/assets/javascripts/ui_models/application_group.ts index 63766016e85..80aa9207352 100644 --- a/app/assets/javascripts/ui_models/application_group.ts +++ b/app/assets/javascripts/ui_models/application_group.ts @@ -26,7 +26,7 @@ export class ApplicationGroup extends SNApplicationGroup { super(new WebDeviceInterface(bridge)); } - async initialize(callback?: any): Promise { + async initialize(): Promise { await super.initialize({ applicationCreator: this.createApplication, }); diff --git a/package.json b/package.json index b0330538145..f3783a7fc31 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "standard-notes-web", - "version": "3.9.20", + "version": "3.9.30-beta.1", "license": "AGPL-3.0-or-later", "repository": { "type": "git",