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
e520b637
Commit
e520b637
authored
Mar 30, 2026
by
memoclaw
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: prevent stale comment drafts from being restored
parent
acbc914d
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
32 additions
and
8 deletions
+32
-8
cacheService.ts
web/src/components/MemoEditor/services/cacheService.ts
+32
-8
No files found.
web/src/components/MemoEditor/services/cacheService.ts
View file @
e520b637
import
{
debounce
}
from
"lodash-es"
;
export
const
CACHE_DEBOUNCE_DELAY
=
500
;
export
const
CACHE_DEBOUNCE_DELAY
=
500
;
const
pendingSaves
=
new
Map
<
string
,
ReturnType
<
typeof
window
.
setTimeout
>>
();
export
const
cacheService
=
{
export
const
cacheService
=
{
key
:
(
username
:
string
,
cacheKey
?:
string
):
string
=>
{
key
:
(
username
:
string
,
cacheKey
?:
string
):
string
=>
{
return
`
${
username
}
-
${
cacheKey
||
""
}
`
;
return
`
${
username
}
-
${
cacheKey
||
""
}
`
;
},
},
save
:
debounce
((
key
:
string
,
content
:
string
)
=>
{
save
:
(
key
:
string
,
content
:
string
)
=>
{
if
(
content
.
trim
())
{
const
pendingSave
=
pendingSaves
.
get
(
key
);
localStorage
.
setItem
(
key
,
content
);
if
(
pendingSave
)
{
}
else
{
window
.
clearTimeout
(
pendingSave
);
localStorage
.
removeItem
(
key
);
}
}
},
CACHE_DEBOUNCE_DELAY
),
const
timeoutId
=
window
.
setTimeout
(()
=>
{
pendingSaves
.
delete
(
key
);
if
(
content
.
trim
())
{
localStorage
.
setItem
(
key
,
content
);
}
else
{
localStorage
.
removeItem
(
key
);
}
},
CACHE_DEBOUNCE_DELAY
);
pendingSaves
.
set
(
key
,
timeoutId
);
},
load
(
key
:
string
):
string
{
load
(
key
:
string
):
string
{
return
localStorage
.
getItem
(
key
)
||
""
;
return
localStorage
.
getItem
(
key
)
||
""
;
},
},
clear
(
key
:
string
):
void
{
clear
(
key
:
string
):
void
{
const
pendingSave
=
pendingSaves
.
get
(
key
);
if
(
pendingSave
)
{
window
.
clearTimeout
(
pendingSave
);
pendingSaves
.
delete
(
key
);
}
localStorage
.
removeItem
(
key
);
localStorage
.
removeItem
(
key
);
},
},
clearAll
():
void
{
for
(
const
timeoutId
of
pendingSaves
.
values
())
{
window
.
clearTimeout
(
timeoutId
);
}
pendingSaves
.
clear
();
},
};
};
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