From b9e34e422770cfb4f14435fb84e9aed7e4b72f2a Mon Sep 17 00:00:00 2001 From: Salihu Date: Thu, 4 Dec 2025 22:55:42 +0100 Subject: [PATCH] code cleanup --- app/components/BulkSelectionToolbar.tsx | 14 +++++++------- app/scenes/DocumentArchive.tsx | 2 +- app/scenes/DocumentDelete.tsx | 10 ++++++---- shared/i18n/locales/en_US/translation.json | 5 ++--- 4 files changed, 16 insertions(+), 15 deletions(-) diff --git a/app/components/BulkSelectionToolbar.tsx b/app/components/BulkSelectionToolbar.tsx index c7627bedc5..4bae482222 100644 --- a/app/components/BulkSelectionToolbar.tsx +++ b/app/components/BulkSelectionToolbar.tsx @@ -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) => { diff --git a/app/scenes/DocumentArchive.tsx b/app/scenes/DocumentArchive.tsx index d83d405dab..ed2a4d647c 100644 --- a/app/scenes/DocumentArchive.tsx +++ b/app/scenes/DocumentArchive.tsx @@ -77,7 +77,7 @@ function DocumentArchive({ documents, onSubmit }: Props) { {isBulkAction ? ( }} /> diff --git a/app/scenes/DocumentDelete.tsx b/app/scenes/DocumentDelete.tsx index 962ff43225..0b2453df99 100644 --- a/app/scenes/DocumentDelete.tsx +++ b/app/scenes/DocumentDelete.tsx @@ -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] diff --git a/shared/i18n/locales/en_US/translation.json b/shared/i18n/locales/en_US/translation.json index 73f49616dc..52bdb36a22 100644 --- a/shared/i18n/locales/en_US/translation.json +++ b/shared/i18n/locales/en_US/translation.json @@ -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 {{ count }} documents? They will be removed from collections and search results.": "Are you sure you want to archive {{ count }} documents? They will be removed from collections and search results.", - "Are you sure you want to archive {{ count }} documents? They will be removed from collections and search results._plural": "Are you sure you want to archive {{ count }} documents? They will be removed from collections and search results.", + "Are you sure you want to archive these {{ count }} documents? They will be removed from collections and search results.": "Are you sure you want to archive these {{ count }} documents? They will be removed from collections and search results.", + "Are you sure you want to archive these {{ count }} documents? They will be removed from collections and search results._plural": "Are you sure you want to archive these {{ count }} documents? 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?",