chore: update redux store and service

This commit is contained in:
boojack
2022-05-22 11:01:20 +08:00
parent c3c2882dc5
commit a580df5c9f
27 changed files with 199 additions and 307 deletions

View File

@ -33,16 +33,8 @@ const Memo: React.FC<Props> = (props: Props) => {
try {
if (memo.pinned) {
await memoService.unpinMemo(memo.id);
memoService.editMemo({
...memo,
pinned: false,
});
} else {
await memoService.pinMemo(memo.id);
memoService.editMemo({
...memo,
pinned: true,
});
}
} catch (error) {
// do nth
@ -50,23 +42,26 @@ const Memo: React.FC<Props> = (props: Props) => {
};
const handleMarkMemoClick = () => {
editorStateService.setMarkMemo(memo.id);
editorStateService.setMarkMemoWithId(memo.id);
};
const handleEditMemoClick = () => {
editorStateService.setEditMemo(memo.id);
editorStateService.setEditMemoWithId(memo.id);
};
const handleDeleteMemoClick = async () => {
if (showConfirmDeleteBtn) {
try {
await memoService.archiveMemoById(memo.id);
await memoService.patchMemo({
id: memo.id,
rowStatus: "ARCHIVED",
});
} catch (error: any) {
toastHelper.error(error.message);
}
if (editorStateService.getState().editMemoId === memo.id) {
editorStateService.setEditMemo(UNKNOWN_ID);
editorStateService.clearEditMemo();
}
} else {
toggleConfirmDeleteBtn();