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
74769b33
Commit
74769b33
authored
Jul 17, 2025
by
Johnny
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: user state
parent
e3735d2d
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
24 additions
and
24 deletions
+24
-24
HomeSidebar.tsx
web/src/components/HomeSidebar/HomeSidebar.tsx
+0
-23
HomeLayout.tsx
web/src/layouts/HomeLayout.tsx
+24
-1
No files found.
web/src/components/HomeSidebar/HomeSidebar.tsx
View file @
74769b33
import
{
last
}
from
"lodash-es"
;
import
{
observer
}
from
"mobx-react-lite"
;
import
{
observer
}
from
"mobx-react-lite"
;
import
{
matchPath
,
useLocation
}
from
"react-router-dom"
;
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
{
cn
}
from
"@/lib/utils"
;
import
{
cn
}
from
"@/lib/utils"
;
import
{
Routes
}
from
"@/router"
;
import
{
memoStore
,
userStore
}
from
"@/store"
;
import
MemoFilters
from
"../MemoFilters"
;
import
MemoFilters
from
"../MemoFilters"
;
import
StatisticsView
from
"../StatisticsView"
;
import
StatisticsView
from
"../StatisticsView"
;
import
ShortcutsSection
from
"./ShortcutsSection"
;
import
ShortcutsSection
from
"./ShortcutsSection"
;
...
@@ -17,26 +12,8 @@ interface Props {
...
@@ -17,26 +12,8 @@ interface Props {
}
}
const
HomeSidebar
=
observer
((
props
:
Props
)
=>
{
const
HomeSidebar
=
observer
((
props
:
Props
)
=>
{
const
location
=
useLocation
();
const
currentUser
=
useCurrentUser
();
const
currentUser
=
useCurrentUser
();
useDebounce
(
async
()
=>
{
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
.
getOrFetchUserByUsername
(
username
||
""
);
parent
=
user
.
name
;
}
await
userStore
.
fetchUserStats
(
parent
);
},
300
,
[
memoStore
.
state
.
memos
.
length
,
userStore
.
state
.
statsStateId
,
location
.
pathname
],
);
return
(
return
(
<
aside
<
aside
className=
{
cn
(
className=
{
cn
(
...
...
web/src/layouts/HomeLayout.tsx
View file @
74769b33
import
{
last
}
from
"lodash-es"
;
import
{
observer
}
from
"mobx-react-lite"
;
import
{
observer
}
from
"mobx-react-lite"
;
import
{
Outlet
}
from
"react-router-dom"
;
import
{
matchPath
,
Outlet
}
from
"react-router-dom"
;
import
{
useDebounce
}
from
"react-use"
;
import
{
HomeSidebar
,
HomeSidebarDrawer
}
from
"@/components/HomeSidebar"
;
import
{
HomeSidebar
,
HomeSidebarDrawer
}
from
"@/components/HomeSidebar"
;
import
MobileHeader
from
"@/components/MobileHeader"
;
import
MobileHeader
from
"@/components/MobileHeader"
;
import
useCurrentUser
from
"@/hooks/useCurrentUser"
;
import
useResponsiveWidth
from
"@/hooks/useResponsiveWidth"
;
import
useResponsiveWidth
from
"@/hooks/useResponsiveWidth"
;
import
{
cn
}
from
"@/lib/utils"
;
import
{
cn
}
from
"@/lib/utils"
;
import
{
Routes
}
from
"@/router"
;
import
{
memoStore
,
userStore
}
from
"@/store"
;
const
HomeLayout
=
observer
(()
=>
{
const
HomeLayout
=
observer
(()
=>
{
const
{
md
,
lg
}
=
useResponsiveWidth
();
const
{
md
,
lg
}
=
useResponsiveWidth
();
const
currentUser
=
useCurrentUser
();
useDebounce
(
async
()
=>
{
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
.
getOrFetchUserByUsername
(
username
||
""
);
parent
=
user
.
name
;
}
await
userStore
.
fetchUserStats
(
parent
);
},
300
,
[
memoStore
.
state
.
memos
.
length
,
userStore
.
state
.
statsStateId
,
location
.
pathname
],
);
return
(
return
(
<
section
className=
"@container w-full min-h-full flex flex-col justify-start items-center"
>
<
section
className=
"@container w-full min-h-full flex flex-col justify-start items-center"
>
...
...
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