diff --git a/src/web/app/common/mios.ts b/src/web/app/common/mios.ts index cf7841d84..838be9c37 100644 --- a/src/web/app/common/mios.ts +++ b/src/web/app/common/mios.ts @@ -52,9 +52,20 @@ export default class MiOS extends EventEmitter { */ private swRegistration: ServiceWorkerRegistration = null; - constructor() { + /** + * Whether should register ServiceWorker + */ + private shouldRegisterSw: boolean; + + /** + * MiOSインスタンスを作成します + * @param shouldRegisterSw ServiceWorkerを登録するかどうか + */ + constructor(shouldRegisterSw = false) { super(); + this.shouldRegisterSw = shouldRegisterSw; + //#region BIND this.log = this.log.bind(this); this.logInfo = this.logInfo.bind(this); @@ -170,7 +181,7 @@ export default class MiOS extends EventEmitter { //#region Post // Init service worker - this.registerSw(); + if (this.shouldRegisterSw) this.registerSw(); //#endregion }; diff --git a/src/web/app/desktop/script.ts b/src/web/app/desktop/script.ts index 694cb7879..b06cb180e 100644 --- a/src/web/app/desktop/script.ts +++ b/src/web/app/desktop/script.ts @@ -40,7 +40,7 @@ init(async (mios: MiOS) => { // Start routing route(mios); -}); +}, true); function registerNotifications(stream: HomeStreamManager) { if (stream == null) return; diff --git a/src/web/app/init.ts b/src/web/app/init.ts index 652cbfde4..19605dc8a 100644 --- a/src/web/app/init.ts +++ b/src/web/app/init.ts @@ -52,8 +52,8 @@ if (localStorage.getItem('should-refresh') == 'true') { } // MiOSを初期化してコールバックする -export default callback => { - const mios = new MiOS(); +export default (callback, sw = false) => { + const mios = new MiOS(sw); mios.init(() => { // ミックスイン初期化 diff --git a/src/web/app/mobile/script.ts b/src/web/app/mobile/script.ts index 74dfe3dfe..4dfff8f72 100644 --- a/src/web/app/mobile/script.ts +++ b/src/web/app/mobile/script.ts @@ -19,4 +19,4 @@ init((mios: MiOS) => { // Start routing route(mios); -}); +}, true);