Kaynağa Gözat

dont change favicon when not needed

Saul Shanabrook 7 yıl önce
ebeveyn
işleme
ecc6e30b21
1 değiştirilmiş dosya ile 10 ekleme ve 4 silme
  1. 10 4
      packages/application-extension/src/index.tsx

+ 10 - 4
packages/application-extension/src/index.tsx

@@ -256,10 +256,16 @@ const notfound: JupyterLabPlugin<void> = {
  */
 const faviconbusy: JupyterLabPlugin<void> = {
   id: '@jupyterlab/application-extension:faviconbusy',
-  activate: async ({serviceManager: {kernels}}: JupyterLab) => {
-    await kernels.ready;
-    kernels.runningChanged.connect((_, kernels) => {
-      const isBusy = kernels.some(kernel => kernel.execution_state === 'busy');
+  activate: async (app: JupyterLab) => {
+    await app.serviceManager.kernels.ready;
+
+    let isBusy = false;
+    app.serviceManager.kernels.runningChanged.connect((_, kernels) => {
+      const newIsBusy = kernels.some(kernel => kernel.execution_state === 'busy');
+      if (newIsBusy === isBusy) {
+        return;
+      }
+      isBusy = newIsBusy;
       const filename = isBusy ? 'favicon-busy-1.ico' : 'favicon.ico';
       const favicon = document.querySelector('link[rel="shortcut icon"]') as HTMLLinkElement;
       favicon.href = `/static/base/images/${filename}`;