Skip to content

Commit

Permalink
fix: Fixed issue where multiple trashed items on mobile could not be …
Browse files Browse the repository at this point in the history
…deleted permanently
  • Loading branch information
amanharwara committed Nov 27, 2023
1 parent bf6f8a8 commit 5660df5
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -382,7 +382,7 @@ const ContentListView = forwardRef<HTMLDivElement, Props>(
)
) : null}
{isMobileScreen && itemListController.isMultipleSelectionMode && (
<MobileMultiSelectionToolbar notesController={notesController} />
<MobileMultiSelectionToolbar notesController={notesController} navigationController={navigationController} />
)}
<div className="absolute bottom-0 h-safe-bottom w-full" />
{children}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
import { NotesController } from '@/Controllers/NotesController/NotesController'
import Icon from '../Icon/Icon'
import { NavigationController } from '@/Controllers/Navigation/NavigationController'
import { observer } from 'mobx-react-lite'
import { SystemViewId, isSmartView } from '@standardnotes/snjs'

type Props = {
notesController: NotesController
navigationController: NavigationController
}

const MobileMultiSelectionToolbar = ({ notesController }: Props) => {
const MobileMultiSelectionToolbar = ({ notesController, navigationController }: Props) => {
const { selectedNotes } = notesController
const { selected } = navigationController

const archived = selectedNotes.some((note) => note.archived)

Expand All @@ -26,7 +31,16 @@ const MobileMultiSelectionToolbar = ({ notesController }: Props) => {
</button>
<button
className="flex-grow px-2 py-3 active:bg-passive-3"
onClick={() => notesController.setTrashSelectedNotes(true).catch(console.error)}
onClick={() => {
const isInTrashView = selected && isSmartView(selected) && selected.uuid === SystemViewId.TrashedNotes
const allSelectedNotesAreTrashed = selectedNotes.every((note) => note.trashed)
const shouldDeletePermanently = isInTrashView || allSelectedNotesAreTrashed
if (shouldDeletePermanently) {
notesController.deleteNotesPermanently().catch(console.error)
} else {
notesController.setTrashSelectedNotes(true).catch(console.error)
}
}}
>
<Icon type="trash" className="mx-auto text-info" size="large" />
</button>
Expand All @@ -40,4 +54,4 @@ const MobileMultiSelectionToolbar = ({ notesController }: Props) => {
)
}

export default MobileMultiSelectionToolbar
export default observer(MobileMultiSelectionToolbar)
1 change: 1 addition & 0 deletions packages/web/src/javascripts/Constants/Strings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ export const Strings = {
protectingNoteWithoutProtectionSources:
'Access to this note will not be restricted until you set up a passcode or account.',
trashItemsTitle: 'Move to Trash',
deleteItemsPermanentlyTitle: 'Delete Permanently',
trashNotesText: 'Are you sure you want to move these notes to the trash?',
trashFilesText: 'Are you sure you want to move these files to the trash?',
enterPasscode: 'Please enter a passcode.',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ export class NotesController
return false
}

const title = Strings.trashItemsTitle
const title = permanently ? Strings.deleteItemsPermanentlyTitle : Strings.trashItemsTitle
let noteTitle = undefined
if (this.selectedNotesCount === 1) {
const selectedNote = this.getSelectedNotesList()[0]
Expand Down

0 comments on commit 5660df5

Please sign in to comment.