Procházet zdrojové kódy

fix performance problem

Yuki Takei před 4 roky
rodič
revize
0ab6197c40
1 změnil soubory, kde provedl 3 přidání a 1 odebrání
  1. 3 1
      packages/app/src/stores/search.tsx

+ 3 - 1
packages/app/src/stores/search.tsx

@@ -69,8 +69,10 @@ export const useSWRxFullTextSearch = (
   };
   const rawQuery = createSearchQuery(keyword ?? '', fixedConfigurations.includeTrashPages, fixedConfigurations.includeUserPages);
 
+  const isKeywordValid = keyword != null && keyword.length > 0;
+
   const swrResult = useSWRImmutable(
-    keyword == null ? null : ['/search', keyword, fixedConfigurations, termNumber],
+    isKeywordValid ? ['/search', keyword, fixedConfigurations, termNumber] : null,
     (endpoint, keyword, fixedConfigurations) => {
       const {
         limit, offset, sort, order,