浏览代码

dont change favicon when not needed

Saul Shanabrook 7 年之前
父节点
当前提交
ecc6e30b21
共有 1 个文件被更改,包括 10 次插入4 次删除
  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}`;