Ver Fonte

Use `document.hidden` instead of `document.hasFocus()`.

Afshin Darian há 7 anos atrás
pai
commit
bb446ddb43

+ 2 - 2
packages/filebrowser/src/model.ts

@@ -442,8 +442,8 @@ class FileBrowserModel implements IDisposable {
         this.refresh();
         return;
       }
-      if (!document.hasFocus()) {
-        // don't poll when nobody's looking
+      if (document.hidden) {
+        // Don't poll when nobody's looking.
         return;
       }
       let date = new Date().getTime();

+ 4 - 4
packages/services/src/kernel/manager.ts

@@ -44,15 +44,15 @@ class KernelManager implements Kernel.IManager {
 
     // Set up polling.
     this._modelsTimer = (setInterval as any)(() => {
-      if (typeof document !== 'undefined' && !document.hasFocus()) {
-        // don't poll when nobody's looking
+      if (typeof document !== 'undefined' && document.hidden) {
+        // Don't poll when nobody's looking.
         return;
       }
       this._refreshRunning();
     }, 10000);
     this._specsTimer = (setInterval as any)(() => {
-      if (typeof document !== 'undefined' && !document.hasFocus()) {
-        // don't poll when nobody's looking
+      if (typeof document !== 'undefined' && document.hidden) {
+        // Don't poll when nobody's looking.
         return;
       }
       this._refreshSpecs();

+ 4 - 4
packages/services/src/session/manager.ts

@@ -48,15 +48,15 @@ class SessionManager implements Session.IManager {
 
     // Set up polling.
     this._modelsTimer = (setInterval as any)(() => {
-      if (typeof document !== 'undefined' && !document.hasFocus()) {
-        // don't poll when nobody's looking
+      if (typeof document !== 'undefined' && document.hidden) {
+        // Don't poll when nobody's looking.
         return;
       }
       this._refreshRunning();
     }, 10000);
     this._specsTimer = (setInterval as any)(() => {
-      if (typeof document !== 'undefined' && !document.hasFocus()) {
-        // don't poll when nobody's looking
+      if (typeof document !== 'undefined' && document.hidden) {
+        // Don't poll when nobody's looking.
         return;
       }
       this._refreshSpecs();

+ 2 - 2
packages/services/src/terminal/manager.ts

@@ -40,8 +40,8 @@ class TerminalManager implements TerminalSession.IManager {
 
       // Set up polling.
       this._refreshTimer = (setInterval as any)(() => {
-        if (typeof document !== 'undefined' && !document.hasFocus()) {
-          // don't poll when nobody's looking
+        if (typeof document !== 'undefined' && document.hidden) {
+          // Don't poll when nobody's looking.
           return;
         }
         this._refreshRunning();