From 077fe046887314f68c331db79259036dd9fb0876 Mon Sep 17 00:00:00 2001 From: Gregory Brzezinski Date: Fri, 11 Nov 2022 16:44:08 +0300 Subject: [PATCH] Add status callback --- package.json | 2 +- .../loading-screen/loading-screen.component.ts | 6 +++++- src/app/services/go.ts | 12 ++++++++++-- 3 files changed, 16 insertions(+), 4 deletions(-) diff --git a/package.json b/package.json index 97da15f..70e6775 100644 --- a/package.json +++ b/package.json @@ -4,7 +4,7 @@ "scripts": { "ng": "ng", "start": "ng serve", - "build": "ng build", + "build": "ng build --output-hashing none", "watch": "ng build --watch --configuration development", "test": "ng test" }, diff --git a/src/app/components/loading-screen/loading-screen.component.ts b/src/app/components/loading-screen/loading-screen.component.ts index 036e06b..762b72d 100644 --- a/src/app/components/loading-screen/loading-screen.component.ts +++ b/src/app/components/loading-screen/loading-screen.component.ts @@ -1,5 +1,5 @@ import { Component, OnInit, Input } from '@angular/core'; - +import { GoSetStatus } from 'src/app/services/go'; @Component({ templateUrl: './loading-screen.component.html', styleUrls: ['./loading-screen.component.scss'] @@ -14,6 +14,10 @@ export class LoadingScreenComponent implements OnInit { } ngOnInit(): void { + document.addEventListener('GoSetStatus_Callback', (event:any) => { + this.SetStatus(event.detail) + console.log("Set loading screen status: " + event.detail) + }) } } diff --git a/src/app/services/go.ts b/src/app/services/go.ts index 71e3acd..adc38e5 100644 --- a/src/app/services/go.ts +++ b/src/app/services/go.ts @@ -12,10 +12,11 @@ export interface Go extends Window { export interface GoCallback extends Window { SetVersion: (value: string) => void; GoChangeRoute: (value: string) => void; + GoSetStatus: (value: string) => void; } let { GoGetGames, GoRunGame, GoGetSessions, GoRunSession, GoWebViewInit } = window as unknown as Go; -let { SetVersion, GoChangeRoute } = window as unknown as GoCallback; +let { SetVersion, GoChangeRoute, GoSetStatus } = window as unknown as GoCallback; let w = window as unknown as GoCallback; @@ -37,4 +38,11 @@ let w = window as unknown as GoCallback; document.dispatchEvent(event); }; -export { GoGetGames, GoGetSessions, SetVersion, GoRunGame, GoChangeRoute, GoWebViewInit, GoRunSession }; +((window)).GoSetStatus = function (value: T): void { + const event = new CustomEvent('GoSetStatus_Callback', { + detail: value, + }); + document.dispatchEvent(event); +}; + +export { GoGetGames, GoGetSessions, SetVersion, GoRunGame, GoChangeRoute, GoSetStatus, GoWebViewInit, GoRunSession };