Jelajahi Sumber

fix #2407: render all scripts after closing editor

tophf 19 jam lalu
induk
melakukan
4da8873180
1 mengubah file dengan 7 tambahan dan 2 penghapusan
  1. 7 2
      src/options/views/tab-installed.vue

+ 7 - 2
src/options/views/tab-installed.vue

@@ -268,6 +268,7 @@ const registerHotkey = (callback, items) => items.map(([key, condition, caseSens
 ));
 
 const MAX_BATCH_DURATION = 100;
+const RENDER_ALL = 1e9;
 let step = 0;
 
 let columnsForTableMode = [];
@@ -471,7 +472,11 @@ async function onHashChange() {
   }
 }
 async function renderScripts() {
-  if (!store.canRenderScripts || isNaN(state.batchRender.limit)) return;
+  if (!store.canRenderScripts
+  || state.batchRender.limit === RENDER_ALL
+  /* Skip rendering as the editor is being closed right now and we only have 1 script,
+     we'll render in the next call after all scripts data is requested. */
+  || store.title) return;
   const { length } = state.sortedScripts;
   let limit = 9;
   const batchRender = reactive({ limit });
@@ -495,7 +500,7 @@ async function renderScripts() {
     }
   }
   // Completed the potentially slow initial creation, subsequent redraws will be fast
-  if (length && limit >= length) batchRender.limit = NaN;
+  if (length && limit >= length) batchRender.limit = RENDER_ALL;
 }
 function scheduleSearch() {
   try {