mirror of
https://github.com/usememos/memos.git
synced 2025-10-10 22:36:21 +08:00
fix: fetch memo with filter (#346)
This commit is contained in:
parent
9705406b82
commit
cb2e1ae355
2 changed files with 11 additions and 1 deletions
|
@ -103,6 +103,15 @@ const MemoList = () => {
|
||||||
}
|
}
|
||||||
}, [query]);
|
}, [query]);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (isFetching || isComplete) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (sortedMemos.length < DEFAULT_MEMO_LIMIT) {
|
||||||
|
handleFetchMoreClick();
|
||||||
|
}
|
||||||
|
}, [isFetching, isComplete, query, sortedMemos.length]);
|
||||||
|
|
||||||
const handleFetchMoreClick = async () => {
|
const handleFetchMoreClick = async () => {
|
||||||
try {
|
try {
|
||||||
const fetchedMemos = await memoService.fetchMemos(DEFAULT_MEMO_LIMIT, memos.length);
|
const fetchedMemos = await memoService.fetchMemos(DEFAULT_MEMO_LIMIT, memos.length);
|
||||||
|
|
|
@ -42,7 +42,8 @@ const getStateFromLocation = () => {
|
||||||
state.query.tag = urlParams.get("tag") ?? undefined;
|
state.query.tag = urlParams.get("tag") ?? undefined;
|
||||||
state.query.type = (urlParams.get("type") as MemoSpecType) ?? undefined;
|
state.query.type = (urlParams.get("type") as MemoSpecType) ?? undefined;
|
||||||
state.query.text = urlParams.get("text") ?? undefined;
|
state.query.text = urlParams.get("text") ?? undefined;
|
||||||
state.query.shortcutId = Number(urlParams.get("shortcutId")) ?? undefined;
|
const shortcutIdStr = urlParams.get("shortcutId");
|
||||||
|
state.query.shortcutId = shortcutIdStr ? Number(shortcutIdStr) : undefined;
|
||||||
const from = parseInt(urlParams.get("from") ?? "0");
|
const from = parseInt(urlParams.get("from") ?? "0");
|
||||||
const to = parseInt(urlParams.get("to") ?? "0");
|
const to = parseInt(urlParams.get("to") ?? "0");
|
||||||
if (to > from && to !== 0) {
|
if (to > from && to !== 0) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue