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
12fdf930
Commit
12fdf930
authored
Dec 25, 2025
by
Steven
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: invalidate React Query cache after memo reaction changes
parent
9f5a7bb8
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
2 deletions
+7
-2
hooks.ts
web/src/components/MemoReactionListView/hooks.ts
+7
-2
No files found.
web/src/components/MemoReactionListView/hooks.ts
View file @
12fdf930
import
{
useQueryClient
}
from
"@tanstack/react-query"
;
import
{
uniq
}
from
"lodash-es"
;
import
{
uniq
}
from
"lodash-es"
;
import
{
useEffect
,
useState
}
from
"react"
;
import
{
useEffect
,
useState
}
from
"react"
;
import
{
memoServiceClient
,
userServiceClient
}
from
"@/connect"
;
import
{
memoServiceClient
,
userServiceClient
}
from
"@/connect"
;
import
useCurrentUser
from
"@/hooks/useCurrentUser"
;
import
useCurrentUser
from
"@/hooks/useCurrentUser"
;
import
{
memoKeys
}
from
"@/hooks/useMemoQueries"
;
import
type
{
Memo
,
Reaction
}
from
"@/types/proto/api/v1/memo_service_pb"
;
import
type
{
Memo
,
Reaction
}
from
"@/types/proto/api/v1/memo_service_pb"
;
import
type
{
User
}
from
"@/types/proto/api/v1/user_service_pb"
;
import
type
{
User
}
from
"@/types/proto/api/v1/user_service_pb"
;
...
@@ -35,6 +37,7 @@ interface UseReactionActionsOptions {
...
@@ -35,6 +37,7 @@ interface UseReactionActionsOptions {
export
const
useReactionActions
=
({
memo
,
onComplete
}:
UseReactionActionsOptions
)
=>
{
export
const
useReactionActions
=
({
memo
,
onComplete
}:
UseReactionActionsOptions
)
=>
{
const
currentUser
=
useCurrentUser
();
const
currentUser
=
useCurrentUser
();
const
queryClient
=
useQueryClient
();
const
hasReacted
=
(
reactionType
:
string
)
=>
{
const
hasReacted
=
(
reactionType
:
string
)
=>
{
return
memo
.
reactions
.
some
((
r
)
=>
r
.
reactionType
===
reactionType
&&
r
.
creator
===
currentUser
?.
name
);
return
memo
.
reactions
.
some
((
r
)
=>
r
.
reactionType
===
reactionType
&&
r
.
creator
===
currentUser
?.
name
);
...
@@ -57,8 +60,10 @@ export const useReactionActions = ({ memo, onComplete }: UseReactionActionsOptio
...
@@ -57,8 +60,10 @@ export const useReactionActions = ({ memo, onComplete }: UseReactionActionsOptio
reaction
:
{
contentId
:
memo
.
name
,
reactionType
},
reaction
:
{
contentId
:
memo
.
name
,
reactionType
},
});
});
}
}
// Refetch the memo to get updated reactions
// Refetch the memo to get updated reactions and invalidate cache
await
memoServiceClient
.
getMemo
({
name
:
memo
.
name
});
const
updatedMemo
=
await
memoServiceClient
.
getMemo
({
name
:
memo
.
name
});
queryClient
.
setQueryData
(
memoKeys
.
detail
(
memo
.
name
),
updatedMemo
);
queryClient
.
invalidateQueries
({
queryKey
:
memoKeys
.
lists
()
});
}
catch
{
}
catch
{
// skip error
// skip error
}
}
...
...
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