chore: legacy fixes (#2343)

This commit is contained in:
Mo
2023-07-03 08:03:25 -05:00
committed by GitHub
parent 6d5cbcb396
commit d79e7b14b1
14 changed files with 148 additions and 95 deletions

View File

@@ -51,18 +51,21 @@ import { FeatureName } from '@/Controllers/FeatureName'
import { ItemGroupController } from '@/Components/NoteView/Controller/ItemGroupController'
import { VisibilityObserver } from './VisibilityObserver'
import { MomentsService } from '@/Controllers/Moments/MomentsService'
import { purchaseMockSubscription } from '@/Utils/Dev/PurchaseMockSubscription'
import { DevMode } from './DevMode'
export type WebEventObserver = (event: WebAppEvent, data?: unknown) => void
export class WebApplication extends SNApplication implements WebApplicationInterface {
private webServices!: WebServices
private webEventObservers: WebEventObserver[] = []
public itemControllerGroup: ItemGroupController
private mobileWebReceiver?: MobileWebReceiver
private androidBackHandler?: AndroidBackHandler
public readonly itemControllerGroup: ItemGroupController
public readonly routeService: RouteServiceInterface
private visibilityObserver?: VisibilityObserver
private readonly webServices!: WebServices
private readonly webEventObservers: WebEventObserver[] = []
private readonly mobileWebReceiver?: MobileWebReceiver
private readonly androidBackHandler?: AndroidBackHandler
private readonly visibilityObserver?: VisibilityObserver
public readonly devMode?: DevMode
constructor(
deviceInterface: WebOrDesktopDevice,
@@ -91,6 +94,10 @@ export class WebApplication extends SNApplication implements WebApplicationInter
u2fAuthenticatorVerificationPromptFunction: startAuthentication,
})
if (isDev) {
this.devMode = new DevMode(this)
}
makeObservable(this, {
dealloced: observable,
})
@@ -152,7 +159,7 @@ export class WebApplication extends SNApplication implements WebApplicationInter
;(service as { application?: WebApplication }).application = undefined
}
this.webServices = {} as WebServices
;(this.webServices as unknown) = undefined
this.itemControllerGroup.deinit()
;(this.itemControllerGroup as unknown) = undefined
@@ -165,7 +172,7 @@ export class WebApplication extends SNApplication implements WebApplicationInter
if (this.visibilityObserver) {
this.visibilityObserver.deinit()
this.visibilityObserver = undefined
;(this.visibilityObserver as unknown) = undefined
}
} catch (error) {
console.error('Error while deiniting application', error)
@@ -458,12 +465,4 @@ export class WebApplication extends SNApplication implements WebApplicationInter
generateUUID(): string {
return this.options.crypto.generateUUID()
}
dev__purchaseMockSubscription() {
if (!isDev) {
throw new Error('This method is only available in dev mode')
}
void purchaseMockSubscription(this.getUser()?.email as string, 2000)
}
}