chore: implement removeApplication

This commit is contained in:
Mo
2023-07-03 09:21:09 -05:00
parent 27fc4be886
commit 40f8985ede
2 changed files with 21 additions and 10 deletions

View File

@@ -35,8 +35,19 @@ export abstract class WebOrDesktopDevice implements WebOrDesktopDeviceInterface
removeApplication(application: ApplicationInterface): void {
const database = this.databaseForIdentifier(application.identifier)
database.deinit()
this.databases = this.databases.filter((db) => db !== database)
if (database) {
database.deinit()
this.databases = this.databases.filter((db) => db !== database)
}
}
deinit() {
for (const database of this.databases) {
database.deinit()
}
this.databases = []
}
public async getJsonParsedRawStorageValue(key: string): Promise<unknown | undefined> {
@@ -66,14 +77,6 @@ export abstract class WebOrDesktopDevice implements WebOrDesktopDeviceInterface
return { killsApplication: false }
}
deinit() {
for (const database of this.databases) {
database.deinit()
}
this.databases = []
}
async getRawStorageValue(key: string): Promise<string | undefined> {
const result = localStorage.getItem(key)

View File

@@ -152,6 +152,10 @@ export class WebApplication extends SNApplication implements WebApplicationInter
override deinit(mode: DeinitMode, source: DeinitSource): void {
super.deinit(mode, source)
if (!this.isNativeMobileWeb()) {
this.webOrDesktopDevice().removeApplication(this)
}
try {
for (const service of Object.values(this.webServices)) {
if (!service) {
@@ -278,6 +282,10 @@ export class WebApplication extends SNApplication implements WebApplicationInter
return this.deviceInterface as MobileDeviceInterface
}
webOrDesktopDevice(): WebOrDesktopDevice {
return this.deviceInterface as WebOrDesktopDevice
}
public getThemeService() {
return this.webServices.themeService
}