mirror of
https://github.com/usememos/memos.git
synced 2025-03-09 03:53:23 +08:00
feat: handle restore memo when is in archived memo detail page (#3165)
This commit is contained in:
parent
c8baeb86ec
commit
2fe6d606ec
3 changed files with 26 additions and 13 deletions
|
@ -57,24 +57,35 @@ const MemoActionMenu = (props: Props) => {
|
|||
});
|
||||
};
|
||||
|
||||
const handleArchiveMemoClick = async () => {
|
||||
const handleToggleMemoStatusClick = async () => {
|
||||
try {
|
||||
await memoStore.updateMemo(
|
||||
{
|
||||
name: memo.name,
|
||||
rowStatus: RowStatus.ARCHIVED,
|
||||
},
|
||||
["row_status"],
|
||||
);
|
||||
if (memo.rowStatus === RowStatus.ARCHIVED) {
|
||||
await memoStore.updateMemo(
|
||||
{
|
||||
name: memo.name,
|
||||
rowStatus: RowStatus.ACTIVE,
|
||||
},
|
||||
["row_status"],
|
||||
);
|
||||
toast(t("message.restored-successfully"));
|
||||
} else {
|
||||
await memoStore.updateMemo(
|
||||
{
|
||||
name: memo.name,
|
||||
rowStatus: RowStatus.ARCHIVED,
|
||||
},
|
||||
["row_status"],
|
||||
);
|
||||
toast.success(t("message.archived-successfully"));
|
||||
}
|
||||
} catch (error: any) {
|
||||
console.error(error);
|
||||
toast.error(error.response.data.message);
|
||||
return;
|
||||
}
|
||||
|
||||
toast.success("Archived successfully");
|
||||
if (isInMemoDetailPage) {
|
||||
navigateTo("/archived");
|
||||
memo.rowStatus === RowStatus.ARCHIVED ? navigateTo("/") : navigateTo("/archived");
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -120,9 +131,9 @@ const MemoActionMenu = (props: Props) => {
|
|||
{t("common.share")}
|
||||
</MenuItem>
|
||||
)}
|
||||
<MenuItem color="warning" onClick={handleArchiveMemoClick}>
|
||||
<Icon.Archive className="w-4 h-auto" />
|
||||
{t("common.archive")}
|
||||
<MenuItem color="warning" onClick={handleToggleMemoStatusClick}>
|
||||
{memo.rowStatus === RowStatus.ARCHIVED ? <Icon.ArchiveRestore className="w-4 h-auto" /> : <Icon.Archive className="w-4 h-auto" />}
|
||||
{memo.rowStatus === RowStatus.ARCHIVED ? t("common.restore") : t("common.archive")}
|
||||
</MenuItem>
|
||||
<MenuItem color="danger" onClick={handleDeleteMemoClick}>
|
||||
<Icon.Trash className="w-4 h-auto" />
|
||||
|
|
|
@ -312,6 +312,7 @@
|
|||
"no-data": "No data found.",
|
||||
"memos-ready": "all memos are ready",
|
||||
"resource-ready": "all resource are ready",
|
||||
"archived-successfully": "Archived successfully",
|
||||
"restored-successfully": "Restored successfully",
|
||||
"memo-updated-datetime": "Memo created datetime changed.",
|
||||
"invalid-created-datetime": "Invalid created datetime.",
|
||||
|
|
|
@ -126,6 +126,7 @@
|
|||
"private-only": "Bản ghi chú này là riêng tư",
|
||||
"resource-filename-updated": "Tên tệp tài nguyên đã được cập nhật.",
|
||||
"resource-ready": "tất cả tài nguyên đã sẵn sàng",
|
||||
"archived-successfully": "Lưu trữ thành công",
|
||||
"restored-successfully": "Khôi phục thành công",
|
||||
"signup-failed": "Đăng ký thất bại",
|
||||
"succeed-copy-code": "Mã đã được sao chép thành công.",
|
||||
|
|
Loading…
Reference in a new issue