code cleanup

This commit is contained in:
Salihu committed 2025-12-04 22:55:42 +01:00
1 parent b405e1e985
commit b9e34e4227
4 files changed
+16 -15

No files matched your search

+7 -7
View File
@@ -11,7 +11,6 @@ import useStores from "~/hooks/useStores";
import DocumentMove from "~/scenes/DocumentMove";
import DocumentDelete from "~/scenes/DocumentDelete";
import DocumentArchive from "~/scenes/DocumentArchive";
import { toast } from "sonner";
function BulkSelectionToolbar() {
const { t } = useTranslation();
@@ -30,14 +29,15 @@ function BulkSelectionToolbar() {
);
React.useEffect(() => {
if (!canArchiveAll && !canDeleteAll && !canMoveAll) {
if (
!canArchiveAll &&
!canDeleteAll &&
!canMoveAll &&
documents.isSelectionMode
) {
documents.clearSelection();
toast.info(
t("Selection cleared due to changes in permissions or document state.")
);
s;
}
}, [canArchiveAll, canDeleteAll, canMoveAll]);
}, [canArchiveAll, canDeleteAll, canMoveAll, documents.isSelectionMode]);
const handleClear = React.useCallback(
(ev: React.MouseEvent) => {
+1 -1
View File
@@ -77,7 +77,7 @@ function DocumentArchive({ documents, onSubmit }: Props) {
{isBulkAction ? (
<Trans
count={documents.length}
defaults="Are you sure you want to archive <em>{{ count }} documents</em>? They will be removed from collections and search results."
defaults="Are you sure you want to archive these <em>{{ count }} documents</em>? They will be removed from collections and search results."
values={{ count: documents.length }}
components={{ em: <strong /> }}
/>
+6 -4
View File
@@ -80,6 +80,9 @@ function DocumentDelete({ documents, onSubmit }: Props) {
);
}
onSubmit?.();
dialogs.closeAllModals();
// Show toast messages
if (isBulkAction) {
const message = failedIds.length
@@ -115,9 +118,7 @@ function DocumentDelete({ documents, onSubmit }: Props) {
} catch (err) {
toast.error(err.message);
} finally {
onSubmit?.();
setDeleting(false);
dialogs.closeAllModals();
}
},
[
@@ -157,6 +158,9 @@ function DocumentDelete({ documents, onSubmit }: Props) {
);
}
onSubmit?.();
dialogs.closeAllModals();
// Show toast messages
if (isBulkAction) {
const successCount = results.filter(
@@ -176,9 +180,7 @@ function DocumentDelete({ documents, onSubmit }: Props) {
} catch (err) {
toast.error(err.message);
} finally {
onSubmit?.();
setArchiving(false);
dialogs.closeAllModals();
}
},
[documents, dialogs, isBulkAction, t, onSubmit]
+2 -3
View File
@@ -181,7 +181,6 @@
"currently viewing": "currently viewing",
"previously edited": "previously edited",
"You": "You",
"Selection cleared due to changes in permissions or document state.": "Selection cleared due to changes in permissions or document state.",
"Archive {{ count }} documents": "Archive {{ count }} documents",
"Archive {{ count }} documents_plural": "Archive {{ count }} documents",
"Delete {{ count }} documents": "Delete {{ count }} documents",
@@ -790,8 +789,8 @@
"{{ count }} documents archived": "{{ count }} documents archived",
"{{ count }} documents archived_plural": "{{ count }} documents archived",
"{{ errorCount }} documents failed to archive, try again?": "{{ errorCount }} documents failed to archive, try again?",
"Are you sure you want to archive <em>{{ count }} documents</em>? They will be removed from collections and search results.": "Are you sure you want to archive <em>{{ count }} documents</em>? They will be removed from collections and search results.",
"Are you sure you want to archive <em>{{ count }} documents</em>? They will be removed from collections and search results._plural": "Are you sure you want to archive <em>{{ count }} documents</em>? They will be removed from collections and search results.",
"Are you sure you want to archive these <em>{{ count }} documents</em>? They will be removed from collections and search results.": "Are you sure you want to archive these <em>{{ count }} documents</em>? They will be removed from collections and search results.",
"Are you sure you want to archive these <em>{{ count }} documents</em>? They will be removed from collections and search results._plural": "Are you sure you want to archive these <em>{{ count }} documents</em>? They will be removed from collections and search results.",
"Archiving this document will remove it from the collection and search results.": "Archiving this document will remove it from the collection and search results.",
"Couldn’t delete the {{noun}}, try again?": "Couldn’t delete the {{noun}}, try again?",
"{{ errorCount }} documents failed to delete, try again?": "{{ errorCount }} documents failed to delete, try again?",