Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
canifa_note
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Vũ Hoàng Anh
canifa_note
Commits
b897b243
Commit
b897b243
authored
Feb 26, 2025
by
Johnny
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: dynamic fetch user stats
parent
5d1075a6
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
17 additions
and
4 deletions
+17
-4
acl_config.go
server/router/api/v1/acl_config.go
+1
-0
HomeSidebar.tsx
web/src/components/HomeSidebar/HomeSidebar.tsx
+15
-3
Navigation.tsx
web/src/components/Navigation.tsx
+1
-1
No files found.
server/router/api/v1/acl_config.go
View file @
b897b243
...
@@ -14,6 +14,7 @@ var authenticationAllowlistMethods = map[string]bool{
...
@@ -14,6 +14,7 @@ var authenticationAllowlistMethods = map[string]bool{
"/memos.api.v1.UserService/GetUser"
:
true
,
"/memos.api.v1.UserService/GetUser"
:
true
,
"/memos.api.v1.UserService/GetUserByUsername"
:
true
,
"/memos.api.v1.UserService/GetUserByUsername"
:
true
,
"/memos.api.v1.UserService/GetUserAvatarBinary"
:
true
,
"/memos.api.v1.UserService/GetUserAvatarBinary"
:
true
,
"/memos.api.v1.UserService/GetUserStats"
:
true
,
"/memos.api.v1.UserService/ListAllUserStats"
:
true
,
"/memos.api.v1.UserService/ListAllUserStats"
:
true
,
"/memos.api.v1.UserService/SearchUsers"
:
true
,
"/memos.api.v1.UserService/SearchUsers"
:
true
,
"/memos.api.v1.MemoService/GetMemo"
:
true
,
"/memos.api.v1.MemoService/GetMemo"
:
true
,
...
...
web/src/components/HomeSidebar/HomeSidebar.tsx
View file @
b897b243
import
{
last
}
from
"lodash-es"
;
import
{
Globe2Icon
,
HomeIcon
}
from
"lucide-react"
;
import
{
Globe2Icon
,
HomeIcon
}
from
"lucide-react"
;
import
{
NavLink
}
from
"react-router-dom"
;
import
{
matchPath
,
NavLink
,
useLocation
}
from
"react-router-dom"
;
import
useDebounce
from
"react-use/lib/useDebounce"
;
import
useDebounce
from
"react-use/lib/useDebounce"
;
import
SearchBar
from
"@/components/SearchBar"
;
import
SearchBar
from
"@/components/SearchBar"
;
import
useCurrentUser
from
"@/hooks/useCurrentUser"
;
import
useCurrentUser
from
"@/hooks/useCurrentUser"
;
import
{
Routes
}
from
"@/router"
;
import
{
Routes
}
from
"@/router"
;
import
{
useMemoList
,
useUserStatsStore
}
from
"@/store/v1"
;
import
{
useMemoList
,
useUserStatsStore
}
from
"@/store/v1"
;
import
{
userStore
}
from
"@/store/v2"
;
import
{
cn
}
from
"@/utils"
;
import
{
cn
}
from
"@/utils"
;
import
{
useTranslate
}
from
"@/utils/i18n"
;
import
{
useTranslate
}
from
"@/utils/i18n"
;
import
MemoFilters
from
"../MemoFilters"
;
import
MemoFilters
from
"../MemoFilters"
;
...
@@ -25,6 +27,7 @@ interface Props {
...
@@ -25,6 +27,7 @@ interface Props {
const
HomeSidebar
=
(
props
:
Props
)
=>
{
const
HomeSidebar
=
(
props
:
Props
)
=>
{
const
t
=
useTranslate
();
const
t
=
useTranslate
();
const
location
=
useLocation
();
const
currentUser
=
useCurrentUser
();
const
currentUser
=
useCurrentUser
();
const
memoList
=
useMemoList
();
const
memoList
=
useMemoList
();
const
userStatsStore
=
useUserStatsStore
();
const
userStatsStore
=
useUserStatsStore
();
...
@@ -46,10 +49,19 @@ const HomeSidebar = (props: Props) => {
...
@@ -46,10 +49,19 @@ const HomeSidebar = (props: Props) => {
useDebounce
(
useDebounce
(
async
()
=>
{
async
()
=>
{
await
userStatsStore
.
listUserStats
(
currentUser
.
name
);
let
parent
:
string
|
undefined
=
undefined
;
if
(
location
.
pathname
===
Routes
.
ROOT
&&
currentUser
)
{
parent
=
currentUser
.
name
;
}
if
(
matchPath
(
"/u/:username"
,
location
.
pathname
)
!==
null
)
{
const
username
=
last
(
location
.
pathname
.
split
(
"/"
));
const
user
=
await
userStore
.
fetchUserByUsername
(
username
||
""
);
parent
=
user
.
name
;
}
await
userStatsStore
.
listUserStats
(
parent
);
},
},
300
,
300
,
[
memoList
.
size
(),
userStatsStore
.
stateId
,
currentUser
],
[
memoList
.
size
(),
userStatsStore
.
stateId
,
currentUser
,
location
.
pathname
],
);
);
return
(
return
(
...
...
web/src/components/Navigation.tsx
View file @
b897b243
...
@@ -85,7 +85,7 @@ const Navigation = observer((props: Props) => {
...
@@ -85,7 +85,7 @@ const Navigation = observer((props: Props) => {
className
,
className
,
)
}
)
}
>
>
<
div
className=
"w-full px-1 py-
2
flex flex-col justify-start items-start space-y-2 overflow-auto hide-scrollbar shrink"
>
<
div
className=
"w-full px-1 py-
1
flex flex-col justify-start items-start space-y-2 overflow-auto hide-scrollbar shrink"
>
<
BrandBanner
className=
"mb-2"
collapsed=
{
collapsed
}
/>
<
BrandBanner
className=
"mb-2"
collapsed=
{
collapsed
}
/>
{
navLinks
.
map
((
navLink
)
=>
(
{
navLinks
.
map
((
navLink
)
=>
(
<
NavLink
<
NavLink
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment