feat: cache editing memo id (#388)

* feat: cache editing memo id

* chore: update
This commit is contained in:
boojack
2022-10-31 21:39:22 +08:00
committed by GitHub
parent ef5492074e
commit 9d8c9609c3
6 changed files with 46 additions and 27 deletions

View File

@ -54,7 +54,7 @@ const MemoCardDialog: React.FC<Props> = (props: Props) => {
continue;
}
const memoTemp = memoService.getMemoById(id);
const memoTemp = await memoService.getMemoById(id);
if (memoTemp) {
linkMemos.push({
...memoTemp,
@ -83,7 +83,9 @@ const MemoCardDialog: React.FC<Props> = (props: Props) => {
};
fetchLinkedMemos();
setMemo(memoService.getMemoById(memo.id) as Memo);
memoService.getMemoById(memo.id).then((memo) => {
setMemo(memo);
});
}, [memos, memo.id]);
const handleMemoCreatedAtClick = () => {
@ -99,7 +101,7 @@ const MemoCardDialog: React.FC<Props> = (props: Props) => {
if (targetEl.className === "memo-link-text") {
const nextMemoId = targetEl.dataset?.value;
const memoTemp = memoService.getMemoById(Number(nextMemoId) ?? UNKNOWN_ID);
const memoTemp = await memoService.getMemoById(Number(nextMemoId) ?? UNKNOWN_ID);
if (memoTemp) {
const nextMemo = {