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
c4dfb854
Commit
c4dfb854
authored
Dec 25, 2025
by
Steven
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: ensure dispatch is used for actions in useMemoInit hook
parent
28e4ade0
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
10 deletions
+12
-10
useMemoInit.ts
web/src/components/MemoEditor/hooks/useMemoInit.ts
+12
-10
No files found.
web/src/components/MemoEditor/hooks/useMemoInit.ts
View file @
c4dfb854
...
...
@@ -10,7 +10,7 @@ export const useMemoInit = (
username
:
string
,
autoFocus
?:
boolean
,
)
=>
{
const
{
actions
}
=
useEditorContext
();
const
{
actions
,
dispatch
}
=
useEditorContext
();
const
initializedRef
=
useRef
(
false
);
useEffect
(()
=>
{
...
...
@@ -18,28 +18,30 @@ export const useMemoInit = (
initializedRef
.
current
=
true
;
const
init
=
async
()
=>
{
actions
.
setLoading
(
"loading"
,
true
);
dispatch
(
actions
.
setLoading
(
"loading"
,
true
)
);
try
{
if
(
memoName
)
{
// Load existing memo
const
loadedState
=
await
memoService
.
load
(
memoName
);
dispatch
(
actions
.
initMemo
({
content
:
loadedState
.
content
,
metadata
:
loadedState
.
metadata
,
timestamps
:
loadedState
.
timestamps
,
});
}),
);
}
else
{
// Load from cache for new memo
const
cachedContent
=
cacheService
.
load
(
cacheService
.
key
(
username
,
cacheKey
));
if
(
cachedContent
)
{
actions
.
updateContent
(
cachedContent
);
dispatch
(
actions
.
updateContent
(
cachedContent
)
);
}
}
}
catch
(
error
)
{
console
.
error
(
"Failed to initialize editor:"
,
error
);
}
finally
{
actions
.
setLoading
(
"loading"
,
false
);
dispatch
(
actions
.
setLoading
(
"loading"
,
false
)
);
if
(
autoFocus
)
{
setTimeout
(()
=>
{
...
...
@@ -50,5 +52,5 @@ export const useMemoInit = (
};
init
();
},
[
memoName
,
cacheKey
,
username
,
autoFocus
,
actions
,
editorRef
]);
},
[
memoName
,
cacheKey
,
username
,
autoFocus
,
actions
,
dispatch
,
editorRef
]);
};
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