Refactors initDisplayDelay function for readability
[platform/framework/web/wrtjs.git] / wrt_app / src / web_application.ts
index dee5636..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();
   }
 
@@ -247,7 +247,8 @@ export class WebApplication {
       show: false,
       webPreferences: {
         nodeIntegration: options.isAddonAvailable,
-        nodeIntegrationInWorker: false
+        nodeIntegrationInWorker: false,
+        nativeWindowOpen: true,
       },
       webContents: WRTWebContents.create(),
     };
@@ -289,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;
   }
@@ -488,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);
   }