feat: implement unarchive functionality for selected ciphers with state management

This commit is contained in:
shuaiplus
2026-03-23 08:32:43 +08:00
parent 58c029beba
commit 0fc7bd7985
2 changed files with 22 additions and 4 deletions
+22 -1
View File
@@ -700,6 +700,27 @@ function folderName(id: string | null | undefined): string {
}
}
async function handleUnarchiveSelected(cipher: Cipher): Promise<void> {
setBusy(true);
try {
await props.onUnarchive(cipher);
if (sidebarFilter.kind === 'archive') {
const remaining = filteredCiphers.filter((item) => item.id !== cipher.id);
setSelectedMap((prev) => {
const next = { ...prev };
delete next[cipher.id];
return next;
});
setSelectedCipherId(remaining[0]?.id || '');
if (isMobileLayout && remaining.length === 0) {
setMobilePanel('list');
}
}
} finally {
setBusy(false);
}
}
async function confirmBulkArchive(): Promise<void> {
const ids = Object.entries(selectedMap)
.filter(([, selected]) => selected)
@@ -906,7 +927,7 @@ function folderName(id: string | null | undefined): string {
onStartEdit={startEdit}
onDelete={setPendingDelete}
onArchive={(cipher) => setPendingArchive(cipher)}
onUnarchive={props.onUnarchive}
onUnarchive={(cipher) => void handleUnarchiveSelected(cipher)}
/>
)}