From 08a9291964362a17e06e04d2b87b11d48d4f8fcd Mon Sep 17 00:00:00 2001 From: Steven Date: Fri, 31 May 2024 09:06:03 +0800 Subject: [PATCH] chore: update timeline filters --- web/src/pages/Timeline.tsx | 33 +++++++++++++++++---------------- 1 file changed, 17 insertions(+), 16 deletions(-) diff --git a/web/src/pages/Timeline.tsx b/web/src/pages/Timeline.tsx index ec3f520f..aa813c77 100644 --- a/web/src/pages/Timeline.tsx +++ b/web/src/pages/Timeline.tsx @@ -29,7 +29,7 @@ const Timeline = () => { const memoStore = useMemoStore(); const memoList = useMemoList(); const [, setLastVisited] = useLocalStorage("lastVisited", Routes.TIMELINE); - const { tag: tagQuery, text: textQuery } = useFilterWithUrlParams(); + const filter = useFilterWithUrlParams(); const [activityStats, setActivityStats] = useState>({}); const [selectedDateString, setSelectedDateString] = useState(new Date().toDateString()); const [isRequesting, setIsRequesting] = useState(true); @@ -44,21 +44,11 @@ const Timeline = () => { useEffect(() => { memoList.reset(); fetchMemos(""); - }, [selectedDateString, tagQuery, textQuery]); + }, [selectedDateString, filter.text, filter.tag, filter.memoPropertyFilter]); useEffect(() => { (async () => { const filters = [`row_status == "NORMAL"`]; - const contentSearch: string[] = []; - if (textQuery) { - contentSearch.push(JSON.stringify(textQuery)); - } - if (contentSearch.length > 0) { - filters.push(`content_search == [${contentSearch.join(", ")}]`); - } - if (tagQuery) { - filters.push(`tag == "${tagQuery}"`); - } const { stats } = await memoServiceClient.getUserMemosStats({ name: user.name, timezone: Intl.DateTimeFormat().resolvedOptions().timeZone, @@ -79,14 +69,25 @@ const Timeline = () => { setIsRequesting(true); const filters = [`creator == "${user.name}"`, `row_status == "NORMAL"`]; const contentSearch: string[] = []; - if (textQuery) { - contentSearch.push(JSON.stringify(textQuery)); + if (filter.text) { + contentSearch.push(JSON.stringify(filter.text)); } if (contentSearch.length > 0) { filters.push(`content_search == [${contentSearch.join(", ")}]`); } - if (tagQuery) { - filters.push(`tag == "${tagQuery}"`); + if (filter.tag) { + filters.push(`tag == "${filter.tag}"`); + } + if (filter.memoPropertyFilter) { + if (filter.memoPropertyFilter.hasLink) { + filters.push(`has_link == true`); + } + if (filter.memoPropertyFilter.hasTaskList) { + filters.push(`has_task_list == true`); + } + if (filter.memoPropertyFilter.hasCode) { + filters.push(`has_code == true`); + } } if (selectedDateString) { const selectedDateStamp = getTimeStampByDate(selectedDateString);