Skip to content

Commit

Permalink
feat: desktop compatibility, beta 1
Browse files Browse the repository at this point in the history
  • Loading branch information
moughxyz committed Feb 3, 2022
1 parent 333d4c4 commit 0f01d29
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 6 deletions.
14 changes: 12 additions & 2 deletions app/assets/javascripts/app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,22 @@ const startApplication: StartApplication = async function startApplication(
});
}

window.addEventListener('DOMContentLoaded', () => {
const renderApp = () => {
render(
<ApplicationGroupView mainApplicationGroup={mainApplicationGroup} />,
document.body.appendChild(document.createElement('div'))
);
});
};

const domReady =
document.readyState === 'complete' || document.readyState === 'interactive';
if (domReady) {
renderApp();
} else {
window.addEventListener('DOMContentLoaded', () => {
renderApp();
});
}
};

if (IsWebPlatform) {
Expand Down
21 changes: 19 additions & 2 deletions app/assets/javascripts/services/desktopManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<void>;
desktop_requestBackupFile(): Promise<string | undefined>;
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;
Expand Down Expand Up @@ -115,6 +128,10 @@ export class DesktopManager
}
}

desktop_updateAvailable(): void {
this.webApplication.notifyWebEvent(WebAppEvent.NewUpdateAvailable);
}

desktop_windowGainedFocus(): void {
this.webApplication.notifyWebEvent(WebAppEvent.DesktopWindowGainedFocus);
}
Expand Down Expand Up @@ -152,7 +169,7 @@ export class DesktopManager
}
}

async desktop_requestBackupFile() {
async desktop_requestBackupFile(): Promise<string | undefined> {
const data = await this.application.createBackupFile(
this.application.hasProtectionSources()
? EncryptionIntent.FileEncrypted
Expand Down
2 changes: 1 addition & 1 deletion app/assets/javascripts/ui_models/application_group.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export class ApplicationGroup extends SNApplicationGroup {
super(new WebDeviceInterface(bridge));
}

async initialize(callback?: any): Promise<void> {
async initialize(): Promise<void> {
await super.initialize({
applicationCreator: this.createApplication,
});
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down

0 comments on commit 0f01d29

Please sign in to comment.