feat: add restore functionality for deleted items with corresponding UI updates

This commit is contained in:
shuaiplus
2026-05-14 10:40:32 +08:00
parent 3e4c104e1d
commit 7312086f92
12 changed files with 80 additions and 12 deletions
+10
View File
@@ -932,6 +932,11 @@ export function createDemoMainRoutesProps(base: AppMainRoutesProps, notify: Noti
notify('success', t('txt_item_updated'));
},
onDeleteVaultItem: async (cipher) => {
if (cipher.deletedDate || (cipher as { deletedAt?: string | null }).deletedAt) {
state.setCiphers((prev) => prev.filter((item) => item.id !== cipher.id));
notify('success', t('txt_item_deleted_permanently'));
return;
}
const deletedDate = new Date().toISOString();
state.setCiphers((prev) => prev.map((item) => (
item.id === cipher.id ? { ...item, deletedDate, archivedDate: null, revisionDate: deletedDate } : item
@@ -965,6 +970,11 @@ export function createDemoMainRoutesProps(base: AppMainRoutesProps, notify: Noti
state.setCiphers((prev) => prev.filter((item) => !idSet.has(item.id)));
notify('success', t('txt_deleted_selected_items_permanently'));
},
onRestoreVaultItems: async (ids) => {
const idSet = new Set(ids);
state.setCiphers((prev) => prev.map((item) => (idSet.has(item.id) ? { ...item, deletedDate: null } : item)));
notify('success', t('txt_restored_selected_items'));
},
onBulkRestoreVaultItems: async (ids) => {
const idSet = new Set(ids);
state.setCiphers((prev) => prev.map((item) => (idSet.has(item.id) ? { ...item, deletedDate: null } : item)));