diff --git a/app/assets/javascripts/App.tsx b/app/assets/javascripts/App.tsx index 0cb0d0f49..a4df70848 100644 --- a/app/assets/javascripts/App.tsx +++ b/app/assets/javascripts/App.tsx @@ -20,15 +20,15 @@ import { IsWebPlatform, WebAppVersion } from '@/Version' import { Runtime, SNLog } from '@standardnotes/snjs' import { render } from 'preact' import { ApplicationGroupView } from './Components/ApplicationGroupView' -import { Bridge } from './Services/Bridge' -import { BrowserBridge } from './Services/BrowserBridge' -import { StartApplication } from './StartApplication' +import { WebDevice } from './Device/WebDevice' +import { StartApplication } from './Device/StartApplication' import { ApplicationGroup } from './UIModels/ApplicationGroup' import { isDev } from './Utils' +import { WebOrDesktopDevice } from './Device/WebOrDesktopDevice' const startApplication: StartApplication = async function startApplication( defaultSyncServerHost: string, - bridge: Bridge, + device: WebOrDesktopDevice, enableUnfinishedFeatures: boolean, webSocketUrl: string, ) { @@ -37,7 +37,7 @@ const startApplication: StartApplication = async function startApplication( const mainApplicationGroup = new ApplicationGroup( defaultSyncServerHost, - bridge, + device, enableUnfinishedFeatures ? Runtime.Dev : Runtime.Prod, webSocketUrl, ) @@ -70,7 +70,7 @@ const startApplication: StartApplication = async function startApplication( if (IsWebPlatform) { startApplication( window.defaultSyncServer, - new BrowserBridge(WebAppVersion), + new WebDevice(WebAppVersion), window.enabledUnfinishedFeatures, window.websocketUrl, ).catch(console.error) diff --git a/app/assets/javascripts/Components/ApplicationView/index.tsx b/app/assets/javascripts/Components/ApplicationView/index.tsx index 9fe5481f4..af0eb42ac 100644 --- a/app/assets/javascripts/Components/ApplicationView/index.tsx +++ b/app/assets/javascripts/Components/ApplicationView/index.tsx @@ -59,7 +59,11 @@ export class ApplicationView extends PureComponent { } async loadApplication() { - this.application.componentManager.setDesktopManager(this.application.getDesktopService()) + const desktopService = this.application.getDesktopService() + if (desktopService) { + this.application.componentManager.setDesktopManager(desktopService) + } + await this.application.prepareForLaunch({ receiveChallenge: async (challenge) => { const challenges = this.state.challenges.slice() @@ -67,6 +71,7 @@ export class ApplicationView extends PureComponent { this.setState({ challenges: challenges }) }, }) + await this.application.launch() } diff --git a/app/assets/javascripts/Components/ComponentView/index.tsx b/app/assets/javascripts/Components/ComponentView/index.tsx index c12bb4183..826649e2e 100644 --- a/app/assets/javascripts/Components/ComponentView/index.tsx +++ b/app/assets/javascripts/Components/ComponentView/index.tsx @@ -168,14 +168,14 @@ export const ComponentView: FunctionalComponent = observer( useEffect(() => { const unregisterDesktopObserver = application .getDesktopService() - .registerUpdateObserver((updatedComponent: SNComponent) => { + ?.registerUpdateObserver((updatedComponent: SNComponent) => { if (updatedComponent.uuid === component.uuid && updatedComponent.active) { requestReload?.(componentViewer) } }) return () => { - unregisterDesktopObserver() + unregisterDesktopObserver?.() } }, [application, requestReload, componentViewer, component.uuid]) diff --git a/app/assets/javascripts/Components/ConfirmSignoutModal/index.tsx b/app/assets/javascripts/Components/ConfirmSignoutModal/index.tsx index 132b42574..ff5fe6c48 100644 --- a/app/assets/javascripts/Components/ConfirmSignoutModal/index.tsx +++ b/app/assets/javascripts/Components/ConfirmSignoutModal/index.tsx @@ -28,8 +28,8 @@ export const ConfirmSignoutModal = observer(({ application, appState }: Props) = const [localBackupsCount, setLocalBackupsCount] = useState(0) useEffect(() => { - application.bridge.localBackupsCount().then(setLocalBackupsCount).catch(console.error) - }, [appState.accountMenu.signingOut, application.bridge]) + application.desktopDevice?.localBackupsCount().then(setLocalBackupsCount).catch(console.error) + }, [appState.accountMenu.signingOut, application.desktopDevice]) return ( @@ -44,6 +44,7 @@ export const ConfirmSignoutModal = observer(({ application, appState }: Props) =

{STRING_SIGN_OUT_CONFIRMATION}

+ {localBackupsCount > 0 && (
@@ -63,13 +64,14 @@ export const ConfirmSignoutModal = observer(({ application, appState }: Props) =
)} +