Memos is an open-source, self-hosted note-taking app that brings your everyday thoughts together in a personal timeline. Your data stays yours, and you choose what to keep private or share.
Go dockerfossgomarkdownmemomicroblognote-takingnotesopen-sourceown-your-datareactself-hostedsqlitetimeline
feat: handle restore memo when is in archived memo detail page (#3165)
The Anh Nguyen2fe6d606ecf7
diff --git a/web/src/components/MemoActionMenu.tsx b/web/src/components/MemoActionMenu.tsxindex bf4149603..b728d376c 100644--- a/web/src/components/MemoActionMenu.tsx+++ b/web/src/components/MemoActionMenu.tsx@@ -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" />diff --git a/web/src/locales/en.json b/web/src/locales/en.jsonindex 4967dfa28..6d58c8ef4 100644--- a/web/src/locales/en.json+++ b/web/src/locales/en.json@@ -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.",diff --git a/web/src/locales/vi.json b/web/src/locales/vi.jsonindex e0f5c0118..23da84fd3 100644--- a/web/src/locales/vi.json+++ b/web/src/locales/vi.json@@ -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.",