Repository: usememos/memos
File: web/src/pages/ResourcesDashboard.tsx (TypeScript)

Code before:
    }
  };

  const loadAllResources = async (resolve: () => void) => {
    if (!isComplete) {
      loadingState.setLoading();
      resourceStore
        .fetchResourceList()
        .catch((error) => {
          console.error(error);
          toast.error(error.response.data.message);
        })
        .finally(() => {
          loadingState.setFinish();
          setIsComplete(true);
          resolve();
        });
    } else {
      resolve();
    }
  };

  const handleSearchResourceInputChange = (query: string) => {
    // to prevent first tiger when page is loaded
    if (query === queryText) return;
    loadAllResources(() => {
      setQueryText(query);
      setSelectedList([]);
    });
  };

  const resourceList = useMemo(
    () =>
      resources
        .filter((res: Resource) => (queryText === "" ? true : res.filename.toLowerCase().includes(queryText.toLowerCase())))
        .map((resource) =>
          listStyle ? (
            <ResourceItem
              key={resource.id}
              resource={resource}
              handleCheckClick={() => handleCheckBtnClick(resource.id)}
              handleUncheckClick={() => handleUncheckBtnClick(resource.id)}
              handleRenameBtnClick={handleRenameBtnClick}
              handleDeleteResourceBtnClick={handleDeleteResourceBtnClick}
              handlePreviewBtnClick={handlePreviewBtnClick}
              handleCopyResourceLinkBtnClick={handleCopyResourceLinkBtnClick}
            ></ResourceItem>
          ) : (
            <ResourceCard
              key={resource.id}
              resource={resource}

Review comment (suggestion):
```
await fetchAllResources()
setQueryText()
// ...
```

Code after:
    }
  };

  const loadAllResources = async (resolve: (allResources: Resource[]) => void) => {
    if (!isComplete) {
      loadingState.setLoading();
      try {
        const allResources = await resourceStore.fetchResourceList();
        loadingState.setFinish();
        setIsComplete(true);
        resolve(allResources);
      } catch (error: any) {
        console.error(error);
        toast.error(error.response.data.message);
      }
    } else {
      resolve(resources);
    }
  };

  const handleSearchResourceInputChange = async (query: string) => {
    // to prevent first tiger when page is loaded
    if (query === queryText) return;
    await loadAllResources(() => {
      setQueryText(query);
      setSelectedList([]);
    });
  };

  const resourceList = useMemo(
    () =>
      resources
        .filter((res: Resource) => (queryText === "" ? true : res.filename.toLowerCase().includes(queryText.toLowerCase())))
        .map((resource) =>
          listStyle ? (
            <ResourceItem
              key={resource.id}
              resource={resource}
              handleCheckClick={() => handleCheckBtnClick(resource.id)}
              handleUncheckClick={() => handleUncheckBtnClick(resource.id)}
              handleRenameBtnClick={handleRenameBtnClick}
              handleDeleteResourceBtnClick={handleDeleteResourceBtnClick}
              handlePreviewBtnClick={handlePreviewBtnClick}
              handleCopyResourceLinkBtnClick={handleCopyResourceLinkBtnClick}
            ></ResourceItem>
          ) : (
            <ResourceCard
              key={resource.id}
              resource={resource}
              handleCheckClick={() => handleCheckBtnClick(resource.id)}
              handleUncheckClick={() => handleUncheckBtnClick(resource.id)}