Commit 0dfcb1a7 authored by Johnny's avatar Johnny

feat: total memo count

parent 3349311b
...@@ -214,6 +214,8 @@ message UserStats { ...@@ -214,6 +214,8 @@ message UserStats {
// The pinned memos of the user. // The pinned memos of the user.
repeated string pinned_memos = 5; repeated string pinned_memos = 5;
int32 total_memo_count = 6;
message MemoTypeStats { message MemoTypeStats {
int32 link_count = 1; int32 link_count = 1;
int32 code_count = 2; int32 code_count = 2;
......
This diff is collapsed.
...@@ -3277,6 +3277,9 @@ definitions: ...@@ -3277,6 +3277,9 @@ definitions:
items: items:
type: string type: string
description: The pinned memos of the user. description: The pinned memos of the user.
totalMemoCount:
type: integer
format: int32
v1Visibility: v1Visibility:
type: string type: string
enum: enum:
......
...@@ -87,6 +87,7 @@ func (s *APIV1Service) ListAllUserStats(ctx context.Context, _ *v1pb.ListAllUser ...@@ -87,6 +87,7 @@ func (s *APIV1Service) ListAllUserStats(ctx context.Context, _ *v1pb.ListAllUser
if memo.Payload.Property.GetHasIncompleteTasks() { if memo.Payload.Property.GetHasIncompleteTasks() {
userStats.MemoTypeStats.UndoCount++ userStats.MemoTypeStats.UndoCount++
} }
userStats.TotalMemoCount++
} }
userStatsList := []*v1pb.UserStats{} userStatsList := []*v1pb.UserStats{}
for _, userStats := range userStatsMap { for _, userStats := range userStatsMap {
...@@ -142,6 +143,7 @@ func (s *APIV1Service) GetUserStats(ctx context.Context, request *v1pb.GetUserSt ...@@ -142,6 +143,7 @@ func (s *APIV1Service) GetUserStats(ctx context.Context, request *v1pb.GetUserSt
MemoDisplayTimestamps: []*timestamppb.Timestamp{}, MemoDisplayTimestamps: []*timestamppb.Timestamp{},
MemoTypeStats: &v1pb.UserStats_MemoTypeStats{}, MemoTypeStats: &v1pb.UserStats_MemoTypeStats{},
TagCount: map[string]int32{}, TagCount: map[string]int32{},
TotalMemoCount: int32(len(memos)),
} }
for _, memo := range memos { for _, memo := range memos {
displayTs := memo.CreatedTs displayTs := memo.CreatedTs
......
...@@ -79,15 +79,20 @@ const HomeSidebar = observer((props: Props) => { ...@@ -79,15 +79,20 @@ const HomeSidebar = observer((props: Props) => {
key={navLink.id} key={navLink.id}
className={({ isActive }) => className={({ isActive }) =>
cn( cn(
"w-full px-2 rounded-xl border flex flex-row items-center text-sm text-zinc-600 dark:text-gray-400 hover:bg-white hover:border-gray-200 dark:hover:border-zinc-700 dark:hover:bg-zinc-800", "w-full px-2 rounded-xl border flex flex-row items-center justify-between text-sm text-zinc-600 dark:text-gray-400 hover:bg-white hover:border-gray-200 dark:hover:border-zinc-700 dark:hover:bg-zinc-800",
isActive ? "bg-white drop-shadow-sm dark:bg-zinc-800 border-gray-200 dark:border-zinc-700" : "border-transparent", isActive ? "bg-white drop-shadow-sm dark:bg-zinc-800 border-gray-200 dark:border-zinc-700" : "border-transparent",
) )
} }
to={navLink.path} to={navLink.path}
viewTransition viewTransition
> >
{navLink.icon} <div className="flex flex-row items-center">
<span className="ml-2 truncate leading-8">{navLink.title}</span> {navLink.icon}
<span className="ml-2 truncate leading-8">{navLink.title}</span>
</div>
{navLink.path === Routes.ROOT && currentUser && userStore.state.currentUserStats && (
<span className="font-mono text-xs opacity-80">{userStore.state.currentUserStats.totalMemoCount}</span>
)}
</NavLink> </NavLink>
))} ))}
</div> </div>
......
...@@ -26,6 +26,13 @@ class LocalState { ...@@ -26,6 +26,13 @@ class LocalState {
return tagCount; return tagCount;
} }
get currentUserStats() {
if (!this.currentUser) {
return undefined;
}
return this.userStatsByName[this.currentUser];
}
constructor() { constructor() {
makeAutoObservable(this); makeAutoObservable(this);
} }
...@@ -171,7 +178,10 @@ const userStore = (() => { ...@@ -171,7 +178,10 @@ const userStore = (() => {
userStatsByName[user] = userStats; userStatsByName[user] = userStats;
} }
state.setPartial({ state.setPartial({
userStatsByName, userStatsByName: {
...state.userStatsByName,
...userStatsByName,
},
}); });
}; };
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment