From 27fc4be886437d5a258b68c59e3e2b7d52b81be5 Mon Sep 17 00:00:00 2001 From: Mo Date: Mon, 3 Jul 2023 09:08:27 -0500 Subject: [PATCH] chore: fix mobile device interface --- packages/mobile/src/Lib/MobileDevice.ts | 9 --------- packages/mobile/src/MobileWebAppContainer.tsx | 2 -- packages/services/src/Domain/Device/DeviceInterface.ts | 4 ---- .../src/Domain/Device/WebOrDesktopDeviceInterface.ts | 4 ++++ .../web/src/javascripts/Application/WebApplication.ts | 4 +++- packages/web/src/javascripts/Utils/Utils.ts | 8 ++++++-- 6 files changed, 13 insertions(+), 18 deletions(-) diff --git a/packages/mobile/src/Lib/MobileDevice.ts b/packages/mobile/src/Lib/MobileDevice.ts index c7f4cdca7..5bcaf1c50 100644 --- a/packages/mobile/src/Lib/MobileDevice.ts +++ b/packages/mobile/src/Lib/MobileDevice.ts @@ -3,7 +3,6 @@ import { AppleIAPProductId, AppleIAPReceipt, ApplicationIdentifier, - ApplicationInterface, DatabaseKeysLoadChunkResponse, DatabaseLoadOptions, Environment, @@ -80,14 +79,6 @@ export class MobileDevice implements MobileDeviceInterface { await this.removeRawStorageValue(namespacedKey(identifier, RawStorageKey.StorageObject)) } - setApplication(_application: ApplicationInterface): void { - throw new Error('Method not implemented.') - } - - removeApplication(_application: ApplicationInterface): void { - throw new Error('Method not implemented.') - } - async authenticateWithU2F(authenticationOptionsJSONString: string): Promise | null> { const { Fido2ApiModule } = NativeModules diff --git a/packages/mobile/src/MobileWebAppContainer.tsx b/packages/mobile/src/MobileWebAppContainer.tsx index 3c4027bba..0aefcbacb 100644 --- a/packages/mobile/src/MobileWebAppContainer.tsx +++ b/packages/mobile/src/MobileWebAppContainer.tsx @@ -156,8 +156,6 @@ const MobileWebAppContents = ({ destroyAndReload }: { destroyAndReload: () => vo this.messageSender = messageSender } - setApplication() {} - askReactNativeToInvokeInterfaceMethod(functionName, args) { return this.messageSender.askReactNativeToInvokeInterfaceMethod(functionName, args) } diff --git a/packages/services/src/Domain/Device/DeviceInterface.ts b/packages/services/src/Domain/Device/DeviceInterface.ts index aa5037e61..ca0bf6d93 100644 --- a/packages/services/src/Domain/Device/DeviceInterface.ts +++ b/packages/services/src/Domain/Device/DeviceInterface.ts @@ -1,4 +1,3 @@ -import { ApplicationInterface } from './../Application/ApplicationInterface' import { ApplicationIdentifier } from '@standardnotes/common' import { FullyFormedTransferPayload, @@ -34,9 +33,6 @@ export interface DeviceInterface { removeRawStorageValuesForIdentifier(identifier: ApplicationIdentifier): Promise - setApplication(application: ApplicationInterface): void - removeApplication(application: ApplicationInterface): void - /** * On web platforms, databased created may be new. * New databases can be because of new sessions, or if the browser deleted it. diff --git a/packages/services/src/Domain/Device/WebOrDesktopDeviceInterface.ts b/packages/services/src/Domain/Device/WebOrDesktopDeviceInterface.ts index 63ed04ec1..9b9c06bf4 100644 --- a/packages/services/src/Domain/Device/WebOrDesktopDeviceInterface.ts +++ b/packages/services/src/Domain/Device/WebOrDesktopDeviceInterface.ts @@ -1,3 +1,4 @@ +import { ApplicationInterface } from './../Application/ApplicationInterface' import { DeviceInterface } from './DeviceInterface' import { RawKeychainValue } from '@standardnotes/models' @@ -7,4 +8,7 @@ export interface WebOrDesktopDeviceInterface extends DeviceInterface { getKeychainValue(): Promise setKeychainValue(value: RawKeychainValue): Promise + + setApplication(application: ApplicationInterface): void + removeApplication(application: ApplicationInterface): void } diff --git a/packages/web/src/javascripts/Application/WebApplication.ts b/packages/web/src/javascripts/Application/WebApplication.ts index 555bdb4c8..d7e187ccc 100644 --- a/packages/web/src/javascripts/Application/WebApplication.ts +++ b/packages/web/src/javascripts/Application/WebApplication.ts @@ -106,7 +106,9 @@ export class WebApplication extends SNApplication implements WebApplicationInter dealloced: observable, }) - deviceInterface.setApplication(this) + if (!this.isNativeMobileWeb()) { + deviceInterface.setApplication(this) + } this.itemControllerGroup = new ItemGroupController(this) this.routeService = new RouteService(this, this.internalEventBus) diff --git a/packages/web/src/javascripts/Utils/Utils.ts b/packages/web/src/javascripts/Utils/Utils.ts index 18856780c..de9b30374 100644 --- a/packages/web/src/javascripts/Utils/Utils.ts +++ b/packages/web/src/javascripts/Utils/Utils.ts @@ -15,7 +15,11 @@ export function getPlatformString() { try { const platform = navigator.platform.toLowerCase() let trimmed = '' - if (platform.includes('mac')) { + if (platform.includes('iphone')) { + trimmed = 'ios' + } else if (platform.includes('android')) { + trimmed = 'android' + } else if (platform.includes('mac')) { trimmed = 'mac' } else if (platform.includes('win')) { trimmed = 'windows' @@ -27,7 +31,7 @@ export function getPlatformString() { } return trimmed + (isDesktopApplication() ? '-desktop' : '-web') } catch (e) { - return 'linux-web' + return 'unknown-platform' } }