From 957df0f518550850d777b644581b5c4d9956305a Mon Sep 17 00:00:00 2001 From: DongHyun Song Date: Wed, 6 Jan 2021 14:35:30 +0900 Subject: [PATCH] Refactors initDisplayDelay function for readability Segregates two parts according to 'firstLaunch'. If first launch, - handle splash screen (place out of 'initDisplayDelay()') - add delay show event If not first launch - enable window Change-Id: Ic8104bc683bf3785581c4c3e6582d3fe738bed89 Signed-off-by: DongHyun Song --- wrt_app/src/web_application.ts | 34 ++++++++++++++++++---------------- 1 file changed, 18 insertions(+), 16 deletions(-) diff --git a/wrt_app/src/web_application.ts b/wrt_app/src/web_application.ts index a48dfa2..e6cc16c 100644 --- a/wrt_app/src/web_application.ts +++ b/wrt_app/src/web_application.ts @@ -70,7 +70,7 @@ export class WebApplication { this.setupEventListener(options); this.mainWindow = new WRTWindow(this.getWindowOption(options)); - this.initDisplayDelay(true); + this.initDisplayDelay(); this.setupMainWindowEventListener(); } @@ -290,26 +290,28 @@ export class WebApplication { }); } - private initDisplayDelay(firstLaunch: boolean) { - // TODO: On 6.0, this causes a black screen on relaunch - if (firstLaunch) - this.firstRendered = false; + private enableWindow() { this.suspended = false; + // TODO: On 6.0, this causes a black screen on relaunch if (this.showTimer) clearTimeout(this.showTimer); - let splashShown = this.preloadStatus !== 'preload' && firstLaunch && wrt.showSplashScreen(); - if (!splashShown && !wrt.tv) { - this.showTimer = setTimeout(() => { - if (!this.suspended) { - console.log('FrameRendered not obtained from engine. To show window, timer fired'); - this.mainWindow.emit('ready-to-show'); - } - }, 2000); - } - if (!firstLaunch && !this.backgroundRunnable()) + if (!this.backgroundRunnable()) this.mainWindow.setEnabled(true); } + private initDisplayDelay() { + let splashShown = this.preloadStatus !== 'preload' && wrt.showSplashScreen(); + if (splashShown || wrt.tv) + return; + + this.showTimer = setTimeout(() => { + if (!this.suspended) { + console.log('FrameRendered not obtained from engine. To show window, timer fired'); + this.mainWindow.emit('ready-to-show'); + } + }, 2000); + } + private backgroundRunnable(): boolean { return this.backgroundSupport || this.backgroundExecution; } @@ -489,7 +491,7 @@ Then you can get profile log from the initial loading.`; private handleAppControlReload(url: string) { console.log('WebApplication : handleAppControlReload'); this.closeWindows(); - this.initDisplayDelay(false); + this.enableWindow(); this.mainWindow.loadURL(url); } -- 2.7.4