mirror of https://github.com/usememos/memos.git
fix: clean duplicated requests
This commit is contained in:
parent
1f7a90cec4
commit
7817947f66
|
|
@ -29,7 +29,14 @@ const TagsSection = (props: Props) => {
|
|||
.sort((a, b) => a[0].localeCompare(b[0]))
|
||||
.sort((a, b) => b[1] - a[1]);
|
||||
|
||||
useDebounce(() => fetchTags(), 300, [memoList.size(), location.pathname]);
|
||||
useDebounce(
|
||||
() => {
|
||||
if (memoList.size() === 0) return;
|
||||
fetchTags();
|
||||
},
|
||||
300,
|
||||
[memoList.size(), location.pathname],
|
||||
);
|
||||
|
||||
const fetchTags = async () => {
|
||||
await tagStore.fetchTags({ user, location });
|
||||
|
|
|
|||
|
|
@ -39,6 +39,8 @@ const AddMemoRelationPopover = (props: Props) => {
|
|||
|
||||
useDebounce(
|
||||
async () => {
|
||||
if (!popoverOpen) return;
|
||||
|
||||
setIsFetching(true);
|
||||
try {
|
||||
const filters = [`creator == "${user.name}"`, `row_status == "NORMAL"`];
|
||||
|
|
@ -57,7 +59,7 @@ const AddMemoRelationPopover = (props: Props) => {
|
|||
setIsFetching(false);
|
||||
},
|
||||
300,
|
||||
[searchText],
|
||||
[popoverOpen, searchText],
|
||||
);
|
||||
|
||||
const getHighlightedContent = (content: string) => {
|
||||
|
|
|
|||
|
|
@ -1,8 +1,9 @@
|
|||
import { Dropdown, IconButton, Menu, MenuButton } from "@mui/joy";
|
||||
import { HashIcon } from "lucide-react";
|
||||
import { useEffect, useRef, useState } from "react";
|
||||
import { useRef, useState } from "react";
|
||||
import useClickAway from "react-use/lib/useClickAway";
|
||||
import OverflowTip from "@/components/kit/OverflowTip";
|
||||
import useAsyncEffect from "@/hooks/useAsyncEffect";
|
||||
import useCurrentUser from "@/hooks/useCurrentUser";
|
||||
import { useTagStore } from "@/store/v1";
|
||||
import { useTranslate } from "@/utils/i18n";
|
||||
|
|
@ -21,15 +22,15 @@ const TagSelector = (props: Props) => {
|
|||
const tags = tagStore.sortedTags();
|
||||
const user = useCurrentUser();
|
||||
|
||||
useEffect(() => {
|
||||
(async () => {
|
||||
try {
|
||||
await tagStore.fetchTags({ user });
|
||||
} catch (error) {
|
||||
// do nothing.
|
||||
}
|
||||
})();
|
||||
}, []);
|
||||
useAsyncEffect(async () => {
|
||||
if (!open) return;
|
||||
|
||||
try {
|
||||
await tagStore.fetchTags({ user });
|
||||
} catch (error) {
|
||||
// do nothing.
|
||||
}
|
||||
}, [open]);
|
||||
|
||||
useClickAway(containerRef, () => {
|
||||
setOpen(false);
|
||||
|
|
|
|||
|
|
@ -312,7 +312,6 @@ const MemoEditor = (props: Props) => {
|
|||
memoPatch.relations = state.relationList;
|
||||
}
|
||||
const memo = await memoStore.updateMemo(memoPatch, updateMask);
|
||||
await memoStore.getOrFetchMemoByName(memo.name, { skipCache: true });
|
||||
if (onConfirm) {
|
||||
onConfirm(memo.name);
|
||||
}
|
||||
|
|
@ -338,7 +337,6 @@ const MemoEditor = (props: Props) => {
|
|||
})
|
||||
.then((memo) => memo);
|
||||
const memo = await request;
|
||||
await memoStore.getOrFetchMemoByName(memo.name, { skipCache: true });
|
||||
if (onConfirm) {
|
||||
onConfirm(memo.name);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ import { memoServiceClient } from "@/grpcweb";
|
|||
import useAsyncEffect from "@/hooks/useAsyncEffect";
|
||||
import useCurrentUser from "@/hooks/useCurrentUser";
|
||||
import i18n from "@/i18n";
|
||||
import { useMemoFilterStore, useMemoStore } from "@/store/v1";
|
||||
import { useMemoFilterStore, useMemoList, useMemoStore } from "@/store/v1";
|
||||
import { useTranslate } from "@/utils/i18n";
|
||||
import ActivityCalendar from "./ActivityCalendar";
|
||||
import { Popover, PopoverContent, PopoverTrigger } from "./ui/Popover";
|
||||
|
|
@ -25,6 +25,7 @@ const UserStatisticsView = () => {
|
|||
const t = useTranslate();
|
||||
const currentUser = useCurrentUser();
|
||||
const memoStore = useMemoStore();
|
||||
const memoList = useMemoList();
|
||||
const memoFilterStore = useMemoFilterStore();
|
||||
const [memoAmount, setMemoAmount] = useState(0);
|
||||
const [memoStats, setMemoStats] = useState<UserMemoStats>({ link: 0, taskList: 0, code: 0, incompleteTasks: 0 });
|
||||
|
|
@ -34,6 +35,8 @@ const UserStatisticsView = () => {
|
|||
const days = Math.ceil((Date.now() - currentUser.createTime!.getTime()) / 86400000);
|
||||
|
||||
useAsyncEffect(async () => {
|
||||
if (memoList.size() === 0) return;
|
||||
|
||||
const { entities } = await memoServiceClient.listMemoProperties({
|
||||
name: `memos/-`,
|
||||
});
|
||||
|
|
|
|||
Loading…
Reference in New Issue