Refactors initDisplayDelay function for readability 58/250958/4
authorDongHyun Song <dh81.song@samsung.com>
Wed, 6 Jan 2021 05:35:30 +0000 (14:35 +0900)
committerDongHyun Song <dh81.song@samsung.com>
Fri, 22 Jan 2021 04:28:20 +0000 (13:28 +0900)
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 <dh81.song@samsung.com>
wrt_app/src/web_application.ts

index a48dfa2..e6cc16c 100644 (file)
@@ -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);
   }