Manifest v3: Fix Controller dispatch

This commit is contained in:
Marcel Klehr 2023-05-30 16:02:16 +02:00
Родитель 71f41322b7
Коммит 8ec03ba430
3 изменённых файлов: 22 добавлений и 4 удалений

Просмотреть файл

@ -1,11 +1,22 @@
import IController from './interfaces/Controller'
import { Capacitor } from '@capacitor/core'
export default class Controller implements IController {
static singleton: IController
static async getSingleton():Promise<IController> {
if (!this.singleton) {
this.singleton = new Controller
// eslint-disable-next-line no-undef
if (typeof WorkerGlobalScope !== 'undefined' && self instanceof WorkerGlobalScope) {
if (Capacitor.getPlatform() === 'web') {
this.singleton = new (await import('./browser/BrowserController')).default
} else {
this.singleton = new (await import('./native/NativeController')).default
}
return this.singleton
} else {
this.singleton = new Controller
}
}
return this.singleton
}
@ -54,7 +65,7 @@ export default class Controller implements IController {
syncAccount(accountId, strategy): Promise<void> {
return navigator.serviceWorker.ready.then((registration) => {
const worker = registration.active
worker.postMessage({type: 'setEnabled', params: [accountId, strategy]})
worker.postMessage({type: 'syncAccount', params: [accountId, strategy]})
})
}

Просмотреть файл

@ -372,7 +372,7 @@ export default class BrowserController {
}
if (icon[status]) {
await browser.browserAction.setIcon(icon[status])
await browser.action.setIcon(icon[status])
}
}

Просмотреть файл

@ -9,7 +9,14 @@
"noImplicitThis": true,
"esModuleInterop": true,
"resolveJsonModule": true,
"lib": ["DOM" ,"es2015", "es2016", "es2017", "es2019"]
"lib": [
"DOM",
"es2015",
"es2016",
"es2017",
"es2019",
"webworker"
]
},
"exclude": [
"node_modules",