chore: fix mobile device interface

This commit is contained in:
Mo
2023-07-03 09:08:27 -05:00
parent 96f42643a9
commit 27fc4be886
6 changed files with 13 additions and 18 deletions

View File

@@ -3,7 +3,6 @@ import {
AppleIAPProductId, AppleIAPProductId,
AppleIAPReceipt, AppleIAPReceipt,
ApplicationIdentifier, ApplicationIdentifier,
ApplicationInterface,
DatabaseKeysLoadChunkResponse, DatabaseKeysLoadChunkResponse,
DatabaseLoadOptions, DatabaseLoadOptions,
Environment, Environment,
@@ -80,14 +79,6 @@ export class MobileDevice implements MobileDeviceInterface {
await this.removeRawStorageValue(namespacedKey(identifier, RawStorageKey.StorageObject)) 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<Record<string, unknown> | null> { async authenticateWithU2F(authenticationOptionsJSONString: string): Promise<Record<string, unknown> | null> {
const { Fido2ApiModule } = NativeModules const { Fido2ApiModule } = NativeModules

View File

@@ -156,8 +156,6 @@ const MobileWebAppContents = ({ destroyAndReload }: { destroyAndReload: () => vo
this.messageSender = messageSender this.messageSender = messageSender
} }
setApplication() {}
askReactNativeToInvokeInterfaceMethod(functionName, args) { askReactNativeToInvokeInterfaceMethod(functionName, args) {
return this.messageSender.askReactNativeToInvokeInterfaceMethod(functionName, args) return this.messageSender.askReactNativeToInvokeInterfaceMethod(functionName, args)
} }

View File

@@ -1,4 +1,3 @@
import { ApplicationInterface } from './../Application/ApplicationInterface'
import { ApplicationIdentifier } from '@standardnotes/common' import { ApplicationIdentifier } from '@standardnotes/common'
import { import {
FullyFormedTransferPayload, FullyFormedTransferPayload,
@@ -34,9 +33,6 @@ export interface DeviceInterface {
removeRawStorageValuesForIdentifier(identifier: ApplicationIdentifier): Promise<void> removeRawStorageValuesForIdentifier(identifier: ApplicationIdentifier): Promise<void>
setApplication(application: ApplicationInterface): void
removeApplication(application: ApplicationInterface): void
/** /**
* On web platforms, databased created may be new. * On web platforms, databased created may be new.
* New databases can be because of new sessions, or if the browser deleted it. * New databases can be because of new sessions, or if the browser deleted it.

View File

@@ -1,3 +1,4 @@
import { ApplicationInterface } from './../Application/ApplicationInterface'
import { DeviceInterface } from './DeviceInterface' import { DeviceInterface } from './DeviceInterface'
import { RawKeychainValue } from '@standardnotes/models' import { RawKeychainValue } from '@standardnotes/models'
@@ -7,4 +8,7 @@ export interface WebOrDesktopDeviceInterface extends DeviceInterface {
getKeychainValue(): Promise<RawKeychainValue> getKeychainValue(): Promise<RawKeychainValue>
setKeychainValue(value: RawKeychainValue): Promise<void> setKeychainValue(value: RawKeychainValue): Promise<void>
setApplication(application: ApplicationInterface): void
removeApplication(application: ApplicationInterface): void
} }

View File

@@ -106,7 +106,9 @@ export class WebApplication extends SNApplication implements WebApplicationInter
dealloced: observable, dealloced: observable,
}) })
deviceInterface.setApplication(this) if (!this.isNativeMobileWeb()) {
deviceInterface.setApplication(this)
}
this.itemControllerGroup = new ItemGroupController(this) this.itemControllerGroup = new ItemGroupController(this)
this.routeService = new RouteService(this, this.internalEventBus) this.routeService = new RouteService(this, this.internalEventBus)

View File

@@ -15,7 +15,11 @@ export function getPlatformString() {
try { try {
const platform = navigator.platform.toLowerCase() const platform = navigator.platform.toLowerCase()
let trimmed = '' 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' trimmed = 'mac'
} else if (platform.includes('win')) { } else if (platform.includes('win')) {
trimmed = 'windows' trimmed = 'windows'
@@ -27,7 +31,7 @@ export function getPlatformString() {
} }
return trimmed + (isDesktopApplication() ? '-desktop' : '-web') return trimmed + (isDesktopApplication() ? '-desktop' : '-web')
} catch (e) { } catch (e) {
return 'linux-web' return 'unknown-platform'
} }
} }