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

Code before:
    toast.success(t("message.succeed-copy-resource-link"));
  };

  const handleFetchMoreResourceBtnClick = async () => {
    try {
      const fetchedResource = await resourceStore.fetchResourceListWithLimit(DEFAULT_MEMO_LIMIT, resources.length);
      if (fetchedResource.length < DEFAULT_MEMO_LIMIT) {
        setIsComplete(true);
      } else {
        setIsComplete(false);
      }
    } catch (error: any) {
      console.error(error);
      toast.error(error.response.data.message);
    }
  };

  const loadAllResources = async (resolve: (allResources: Resource[]) => void) => {
    if (!isComplete) {
      loadingState.setLoading();
      try {
        await resourceStore.fetchResourceList().then((allResources) => {
          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

Review comment (suggestion):
```suggestion
        const allResources = await resourceStore.fetchResourceList();
        loadingState.setFinish();
        setIsComplete(true);
        resolve(allResources);
```

Code after:
    toast.success(t("message.succeed-copy-resource-link"));
  };

  const handleFetchMoreResourceBtnClick = async () => {
    try {
      const fetchedResource = await resourceStore.fetchResourceListWithLimit(DEFAULT_MEMO_LIMIT, resources.length);
      if (fetchedResource.length < DEFAULT_MEMO_LIMIT) {
        setIsComplete(true);
      } else {
        setIsComplete(false);
      }
    } catch (error: any) {
      console.error(error);
      toast.error(error.response.data.message);
    }
  };

  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}