From fb8f7018fd7a8b7fe7c6a552d20f8b7a7a57a0ce Mon Sep 17 00:00:00 2001 From: DongHyun Song Date: Tue, 6 Jul 2021 17:58:32 +0900 Subject: [PATCH] [VD] if condition clean-up 1) preloadState always has 'preload' when backgroundAtStartup. (preload || !backgroundAtStartup) is same (preload || !preload) It should be 'true' Thus, this condition check is unnecessary. 2) Minor changes Change-Id: Ia6dcbb8a61a4bc8051a4791f290e7e3176fe15f7 Signed-off-by: DongHyun Song --- wrt_app/src/tv/web_application_tv.ts | 44 +++++++++++++--------------- 1 file changed, 20 insertions(+), 24 deletions(-) diff --git a/wrt_app/src/tv/web_application_tv.ts b/wrt_app/src/tv/web_application_tv.ts index 85c1ceac..683515fd 100644 --- a/wrt_app/src/tv/web_application_tv.ts +++ b/wrt_app/src/tv/web_application_tv.ts @@ -119,16 +119,16 @@ Then you can get profile log from the initial loading.`; } } + private needSuspend() { + return this.launchMode !== 'runningAsBackground' && + (this.preloadStatus === 'preload' || this.runningStatus === 'behind'); + } + private suspendByStatus() { - if (this.launchMode == 'runningAsBackground') { - console.log('WebApplication : runningAsBackground suspend is skipped!'); - return; - } - if (this.preloadStatus === 'preload' || - this.runningStatus === 'behind') { + if (this.needSuspend()) { console.log('WebApplication : suspendByStatus'); console.log(`preloadStatus: ${this.preloadStatus}, runningStatus: ${this.runningStatus}`); - // TODO : Need to care this situation and decide to pass the addon event emitter to suspend() + this.webApplication.suspend(); if (this.preloadStatus === 'preload') this.runningStatus = 'preload'; @@ -136,17 +136,13 @@ Then you can get profile log from the initial loading.`; } } - private handlePreloadState(launchMode: string) { - if (this.preloadStatus === 'preload' || launchMode != 'backgroundAtStartup') - this.preloadStatus = 'none'; - } - backgroundExecutable() { return this.backgroundExecution; } isPreloading() { - if (this.preloadStatus == 'preload' || this.launchMode == 'runningAsBackground') { + if (this.preloadStatus === 'preload' || + this.launchMode === 'runningAsBackground') { console.log(`preloadStatus is ${this.preloadStatus} or ${this.launchMode}, show is skipped`); return true; } @@ -154,8 +150,8 @@ Then you can get profile log from the initial loading.`; } canIgnoreSuspend() { - if (this.launchMode == 'runningAsForeground' || - this.launchMode == 'runningAsBackground') { + if (this.launchMode === 'runningAsForeground' || + this.launchMode === 'runningAsBackground') { console.log('WebApplication : view_suspend & multitasking feature is skipped!'); return true; } @@ -220,7 +216,7 @@ Then you can get profile log from the initial loading.`; handleAppControlEvent(appControl: any) { this.launchMode = appControl.getData('http://samsung.com/appcontrol/data/launch_mode'); - this.handlePreloadState(this.launchMode); + this.preloadStatus = 'none'; if (this.launchMode === 'runningAsBackground') { this.webApplication.suspended = false; @@ -232,14 +228,14 @@ Then you can get profile log from the initial loading.`; this.webApplication.resume(); this.webApplication.sendAppControlEvent(); return false; - } - - let skipReload = appControl.getData('SkipReload'); - if (skipReload == 'Yes') { - console.log('skipping reload'); - // TODO : Need to care this situation and decide to pass the addon event emitter to resume() - this.webApplication.resume(); - return false; + } else { + let skipReload = appControl.getData('SkipReload'); + if (skipReload == 'Yes') { + console.log('skipping reload'); + // TODO : Need to care this situation and decide to pass the addon event emitter to resume() + this.webApplication.resume(); + return false; + } } return true; } -- 2.34.1