From 2b49025f4ae69a07c95e65ab21ccd5fae5dc16b1 Mon Sep 17 00:00:00 2001 From: Steven Date: Tue, 4 Jun 2024 23:03:51 +0800 Subject: [PATCH] chore: update memo filters --- web/src/components/MemoFilter.tsx | 42 +---------------------- web/src/components/UserStatisticsView.tsx | 23 +++++++++---- 2 files changed, 18 insertions(+), 47 deletions(-) diff --git a/web/src/components/MemoFilter.tsx b/web/src/components/MemoFilter.tsx index 534f34fa..bcbf2f50 100644 --- a/web/src/components/MemoFilter.tsx +++ b/web/src/components/MemoFilter.tsx @@ -14,14 +14,7 @@ const MemoFilter = (props: Props) => { const location = useLocation(); const filterStore = useFilterStore(); const filter = filterStore.state; - const showFilter = Boolean( - filter.tag || - filter.text || - filter.visibility || - filter.memoPropertyFilter?.hasLink || - filter.memoPropertyFilter?.hasTaskList || - filter.memoPropertyFilter?.hasCode, - ); + const showFilter = Boolean(filter.tag || filter.text || filter.visibility); useEffect(() => { filterStore.clearFilter(); @@ -75,39 +68,6 @@ const MemoFilter = (props: Props) => { )} - {filter.memoPropertyFilter?.hasLink && ( -
{ - filterStore.setMemoPropertyFilter({ hasLink: false }); - }} - > - Has Link - -
- )} - {filter.memoPropertyFilter?.hasTaskList && ( -
{ - filterStore.setMemoPropertyFilter({ hasTaskList: false }); - }} - > - Has Task - -
- )} - {filter.memoPropertyFilter?.hasCode && ( -
{ - filterStore.setMemoPropertyFilter({ hasCode: false }); - }} - > - Has Code - -
- )} ); }; diff --git a/web/src/components/UserStatisticsView.tsx b/web/src/components/UserStatisticsView.tsx index f5c56242..c5a12a20 100644 --- a/web/src/components/UserStatisticsView.tsx +++ b/web/src/components/UserStatisticsView.tsx @@ -1,4 +1,5 @@ import { Divider, Tooltip } from "@mui/joy"; +import clsx from "clsx"; import { useState } from "react"; import toast from "react-hot-toast"; import { memoServiceClient } from "@/grpcweb"; @@ -29,6 +30,7 @@ const UserStatisticsView = (props: Props) => { const [memoStats, setMemoStats] = useState({ links: 0, todos: 0, code: 0 }); const days = Math.ceil((Date.now() - user.createTime!.getTime()) / 86400000); const memos = Object.values(memoStore.getState().memoMapByName); + const filter = filterStore.state; useAsyncEffect(async () => { setIsRequesting(true); @@ -91,8 +93,11 @@ const UserStatisticsView = (props: Props) => {
filterStore.setMemoPropertyFilter({ hasLink: true })} + className={clsx( + "w-auto border dark:border-zinc-800 pl-1 pr-1.5 rounded-md flex justify-between items-center cursor-pointer hover:opacity-80", + filter.memoPropertyFilter?.hasLink ? "bg-blue-50 dark:bg-blue-900 shadow" : "", + )} + onClick={() => filterStore.setMemoPropertyFilter({ hasLink: !filter.memoPropertyFilter?.hasLink })} >
@@ -101,8 +106,11 @@ const UserStatisticsView = (props: Props) => { {memoStats.links}
filterStore.setMemoPropertyFilter({ hasTaskList: true })} + className={clsx( + "w-auto border dark:border-zinc-800 pl-1 pr-1.5 rounded-md flex justify-between items-center cursor-pointer hover:opacity-80", + filter.memoPropertyFilter?.hasTaskList ? "bg-blue-50 dark:bg-blue-900 shadow" : "", + )} + onClick={() => filterStore.setMemoPropertyFilter({ hasTaskList: !filter.memoPropertyFilter?.hasTaskList })} >
@@ -111,8 +119,11 @@ const UserStatisticsView = (props: Props) => { {memoStats.todos}
filterStore.setMemoPropertyFilter({ hasCode: true })} + className={clsx( + "w-auto border dark:border-zinc-800 pl-1 pr-1.5 rounded-md flex justify-between items-center cursor-pointer hover:opacity-80", + filter.memoPropertyFilter?.hasCode ? "bg-blue-50 dark:bg-blue-900 shadow" : "", + )} + onClick={() => filterStore.setMemoPropertyFilter({ hasCode: !filter.memoPropertyFilter?.hasCode })} >