chore: update sidebar components

This commit is contained in:
Steven 2024-03-29 09:16:55 +08:00
parent 526f46807e
commit ea6628066d
9 changed files with 26 additions and 32 deletions

View file

@ -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)
}

View file

@ -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) => {
)}
>
<SearchBar />
<UserList />
<UsersSection />
</aside>
);
};

View file

@ -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<User[]>([]);
@ -48,4 +48,4 @@ const UserList = () => {
);
};
export default UserList;
export default UsersSection;

View file

@ -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) => {
>
<SearchBar />
<PersonalStatistics user={currentUser} />
<TagList />
<TagsSection />
</aside>
);
};

View file

@ -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<T = any> {
[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<TagItemContainerProps> = (props: TagItemContain
);
};
export default TagList;
export default TagsSection;

View file

@ -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) => {
)}
>
<SearchBar />
<TagList />
<TagsSection />
</aside>
);
};

View file

@ -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 = () => {

View file

@ -0,0 +1,4 @@
import TimelineSidebar from "./TimelineSidebar";
import TimelineSidebarDrawer from "./TimelineSidebarDrawer";
export { TimelineSidebar, TimelineSidebarDrawer };

View file

@ -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";