diff --git a/src/core/features/emulator/services/network.ts b/src/core/features/emulator/services/network.ts index 7b1f79222..cca7dab97 100644 --- a/src/core/features/emulator/services/network.ts +++ b/src/core/features/emulator/services/network.ts @@ -24,6 +24,9 @@ export class NetworkMock extends Network { type!: string; + protected connectObservable = new Subject<'connected'>(); + protected disconnectObservable = new Subject<'disconnected'>(); + constructor() { super(); @@ -38,6 +41,14 @@ export class NetworkMock extends Network { CELL: 'cellular', // eslint-disable-line @typescript-eslint/naming-convention NONE: 'none', // eslint-disable-line @typescript-eslint/naming-convention }; + + window.addEventListener('online', () => { + this.connectObservable.next('connected'); + }, false); + + window.addEventListener('offline', () => { + this.disconnectObservable.next('disconnected'); + }, false); } /** @@ -45,8 +56,8 @@ export class NetworkMock extends Network { * * @return Observable. */ - onchange(): Observable { - return merge(this.onConnect(), this.onDisconnect()); + onChange(): Observable<'connected' | 'disconnected'> { + return merge(this.connectObservable, this.disconnectObservable); } /** @@ -54,14 +65,8 @@ export class NetworkMock extends Network { * * @return Observable. */ - onConnect(): Observable { - const observable = new Subject(); - - window.addEventListener('online', (ev) => { - observable.next(ev); - }, false); - - return observable; + onConnect(): Observable<'connected'> { + return this.connectObservable; } /** @@ -69,14 +74,8 @@ export class NetworkMock extends Network { * * @return Observable. */ - onDisconnect(): Observable { - const observable = new Subject(); - - window.addEventListener('offline', (ev) => { - observable.next(ev); - }, false); - - return observable; + onDisconnect(): Observable<'disconnected'> { + return this.disconnectObservable; } } diff --git a/src/core/features/mainmenu/pages/menu/menu.scss b/src/core/features/mainmenu/pages/menu/menu.scss index 4f0ebd805..349a0fe15 100644 --- a/src/core/features/mainmenu/pages/menu/menu.scss +++ b/src/core/features/mainmenu/pages/menu/menu.scss @@ -168,11 +168,11 @@ ion-tabs.placement-side { opacity: .8; z-index: 12; - .core-online { + .core-online-message { display: var(--network-message-online); } - .core-offline { + .core-offline-message { display: var(--network-message-offline); } } diff --git a/src/core/initializers/inject-ios-scripts.ts b/src/core/initializers/inject-ios-scripts.ts index a1a728bb2..64b26993d 100644 --- a/src/core/initializers/inject-ios-scripts.ts +++ b/src/core/initializers/inject-ios-scripts.ts @@ -22,5 +22,5 @@ export default async function(): Promise { } await Platform.ready(); - await CoreIframeUtils.injectiOSScripts(window); + CoreIframeUtils.injectiOSScripts(window); }