diff --git a/server/route/api/v2/tag_service.go b/server/route/api/v2/tag_service.go index 35f75fe1..431c596d 100644 --- a/server/route/api/v2/tag_service.go +++ b/server/route/api/v2/tag_service.go @@ -51,22 +51,13 @@ func (s *APIV2Service) BatchUpsertTag(ctx context.Context, request *apiv2pb.Batc } func (s *APIV2Service) ListTags(ctx context.Context, request *apiv2pb.ListTagsRequest) (*apiv2pb.ListTagsResponse, error) { + tagFind := &store.FindTag{} userID, err := ExtractUserIDFromName(request.User) if err != nil { return nil, status.Errorf(codes.InvalidArgument, "invalid user name: %v", err) } - user, err := s.Store.GetUser(ctx, &store.FindUser{ - ID: &userID, - }) - if err != nil { - return nil, status.Errorf(codes.Internal, "failed to get user: %v", err) - } - if user == nil { - return nil, status.Errorf(codes.NotFound, "user not found") - } - tags, err := s.Store.ListTags(ctx, &store.FindTag{ - CreatorID: user.ID, - }) + tagFind.CreatorID = userID + tags, err := s.Store.ListTags(ctx, tagFind) if err != nil { return nil, status.Errorf(codes.Internal, "failed to list tags: %v", err) } diff --git a/web/src/components/ExploreSidebar/ExploreSidebar.tsx b/web/src/components/ExploreSidebar/ExploreSidebar.tsx index 3b2a8a6a..ab2744f5 100644 --- a/web/src/components/ExploreSidebar/ExploreSidebar.tsx +++ b/web/src/components/ExploreSidebar/ExploreSidebar.tsx @@ -1,6 +1,6 @@ import classNames from "classnames"; import SearchBar from "@/components/SearchBar"; -import UserList from "../UserList"; +import UsersSection from "./UsersSection"; interface Props { className?: string; @@ -15,7 +15,7 @@ const ExploreSidebar = (props: Props) => { )} > - + ); }; diff --git a/web/src/components/UserList.tsx b/web/src/components/ExploreSidebar/UsersSection.tsx similarity index 93% rename from web/src/components/UserList.tsx rename to web/src/components/ExploreSidebar/UsersSection.tsx index 25f2568e..f4bb0251 100644 --- a/web/src/components/UserList.tsx +++ b/web/src/components/ExploreSidebar/UsersSection.tsx @@ -3,10 +3,10 @@ import { useEffect, useState } from "react"; import { Link } from "react-router-dom"; import { useUserStore } from "@/store/v1"; import { User } from "@/types/proto/api/v2/user_service"; -import Icon from "./Icon"; -import UserAvatar from "./UserAvatar"; +import Icon from "../Icon"; +import UserAvatar from "../UserAvatar"; -const UserList = () => { +const UsersSection = () => { const userStore = useUserStore(); const [users, setUsers] = useState([]); @@ -48,4 +48,4 @@ const UserList = () => { ); }; -export default UserList; +export default UsersSection; diff --git a/web/src/components/HomeSidebar/HomeSidebar.tsx b/web/src/components/HomeSidebar/HomeSidebar.tsx index c0fec52d..d6fca6fc 100644 --- a/web/src/components/HomeSidebar/HomeSidebar.tsx +++ b/web/src/components/HomeSidebar/HomeSidebar.tsx @@ -1,8 +1,8 @@ import classNames from "classnames"; import PersonalStatistics from "@/components/PersonalStatistics"; import SearchBar from "@/components/SearchBar"; -import TagList from "@/components/TagList"; import useCurrentUser from "@/hooks/useCurrentUser"; +import TagsSection from "./TagsSection"; interface Props { className?: string; @@ -20,7 +20,7 @@ const HomeSidebar = (props: Props) => { > - + ); }; diff --git a/web/src/components/TagList.tsx b/web/src/components/HomeSidebar/TagsSection.tsx similarity index 95% rename from web/src/components/TagList.tsx rename to web/src/components/HomeSidebar/TagsSection.tsx index 2ad1c404..a45c8d35 100644 --- a/web/src/components/TagList.tsx +++ b/web/src/components/HomeSidebar/TagsSection.tsx @@ -4,10 +4,10 @@ import useToggle from "react-use/lib/useToggle"; import { useFilterStore, useTagStore } from "@/store/module"; import { useMemoList } from "@/store/v1"; import { useTranslate } from "@/utils/i18n"; -import showCreateTagDialog from "./CreateTagDialog"; -import { showCommonDialog } from "./Dialog/CommonDialog"; -import Icon from "./Icon"; -import showRenameTagDialog from "./RenameTagDialog"; +import showCreateTagDialog from "../CreateTagDialog"; +import { showCommonDialog } from "../Dialog/CommonDialog"; +import Icon from "../Icon"; +import showRenameTagDialog from "../RenameTagDialog"; interface KVObject { [key: string]: T; @@ -19,7 +19,7 @@ interface Tag { subTags: Tag[]; } -const TagList = () => { +const TagsSection = () => { const t = useTranslate(); const filterStore = useFilterStore(); const tagStore = useTagStore(); @@ -195,4 +195,4 @@ const TagItemContainer: React.FC = (props: TagItemContain ); }; -export default TagList; +export default TagsSection; diff --git a/web/src/components/TimelineSidebar.tsx b/web/src/components/TimelineSidebar/TimelineSidebar.tsx similarity index 78% rename from web/src/components/TimelineSidebar.tsx rename to web/src/components/TimelineSidebar/TimelineSidebar.tsx index 483e12d6..bd670d8e 100644 --- a/web/src/components/TimelineSidebar.tsx +++ b/web/src/components/TimelineSidebar/TimelineSidebar.tsx @@ -1,6 +1,6 @@ import classNames from "classnames"; -import SearchBar from "./SearchBar"; -import TagList from "./TagList"; +import TagsSection from "../HomeSidebar/TagsSection"; +import SearchBar from "../SearchBar"; interface Props { className?: string; @@ -15,7 +15,7 @@ const TimelineSidebar = (props: Props) => { )} > - + ); }; diff --git a/web/src/components/TimelineSidebarDrawer.tsx b/web/src/components/TimelineSidebar/TimelineSidebarDrawer.tsx similarity index 97% rename from web/src/components/TimelineSidebarDrawer.tsx rename to web/src/components/TimelineSidebar/TimelineSidebarDrawer.tsx index a281f99f..175c102a 100644 --- a/web/src/components/TimelineSidebarDrawer.tsx +++ b/web/src/components/TimelineSidebar/TimelineSidebarDrawer.tsx @@ -1,7 +1,7 @@ import { Drawer, IconButton } from "@mui/joy"; import { useEffect, useState } from "react"; import { useLocation } from "react-router-dom"; -import Icon from "./Icon"; +import Icon from "../Icon"; import TimelineSidebar from "./TimelineSidebar"; const TimelineSidebarDrawer = () => { diff --git a/web/src/components/TimelineSidebar/index.ts b/web/src/components/TimelineSidebar/index.ts new file mode 100644 index 00000000..b5dbfcf5 --- /dev/null +++ b/web/src/components/TimelineSidebar/index.ts @@ -0,0 +1,4 @@ +import TimelineSidebar from "./TimelineSidebar"; +import TimelineSidebarDrawer from "./TimelineSidebarDrawer"; + +export { TimelineSidebar, TimelineSidebarDrawer }; diff --git a/web/src/pages/Timeline.tsx b/web/src/pages/Timeline.tsx index a4048d35..95601637 100644 --- a/web/src/pages/Timeline.tsx +++ b/web/src/pages/Timeline.tsx @@ -8,8 +8,7 @@ import showMemoEditorDialog from "@/components/MemoEditor/MemoEditorDialog"; import MemoFilter from "@/components/MemoFilter"; import MemoView from "@/components/MemoView"; import MobileHeader from "@/components/MobileHeader"; -import TimelineSidebar from "@/components/TimelineSidebar"; -import TimelineSidebarDrawer from "@/components/TimelineSidebarDrawer"; +import { TimelineSidebar, TimelineSidebarDrawer } from "@/components/TimelineSidebar"; import { memoServiceClient } from "@/grpcweb"; import { DAILY_TIMESTAMP, DEFAULT_LIST_MEMOS_PAGE_SIZE } from "@/helpers/consts"; import { getNormalizedTimeString, getTimeStampByDate } from "@/helpers/datetime";