chore: show toast when duplicating note and update last modified date for duplicated note (#2379)

This commit is contained in:
Aman Harwara
2023-08-01 18:23:20 +05:30
committed by GitHub
parent 45265fcbad
commit b58898687e
11 changed files with 67 additions and 4 deletions

View File

@@ -55,6 +55,7 @@ const NotesOptions = ({
navigationController,
notesController,
linkingController,
selectionController,
historyModalController,
closeMenu,
}: NotesOptionsProps) => {
@@ -150,10 +151,32 @@ const NotesOptions = ({
}, [closeMenu, toggleAppPane])
const duplicateSelectedItems = useCallback(async () => {
await Promise.all(notes.map((note) => application.mutator.duplicateItem(note).catch(console.error)))
await Promise.all(
notes.map((note) =>
application.mutator
.duplicateItem(note)
.then((duplicated) =>
addToast({
type: ToastType.Regular,
message: `Duplicated note "${duplicated.title}"`,
actions: [
{
label: 'Open',
handler: (toastId) => {
selectionController.selectItem(duplicated.uuid, true).catch(console.error)
dismissToast(toastId)
},
},
],
autoClose: true,
}),
)
.catch(console.error),
),
)
void application.sync.sync()
closeMenuAndToggleNotesList()
}, [application.mutator, application.sync, closeMenuAndToggleNotesList, notes])
}, [application.mutator, application.sync, closeMenuAndToggleNotesList, notes, selectionController])
const openRevisionHistoryModal = useCallback(() => {
historyModalController.openModal(notesController.firstSelectedNote)

View File

@@ -8,12 +8,14 @@ import Popover from '../Popover/Popover'
import { LinkingController } from '@/Controllers/LinkingController'
import RoundIconButton from '../Button/RoundIconButton'
import Menu from '../Menu/Menu'
import { SelectedItemsController } from '@/Controllers/SelectedItemsController'
type Props = {
navigationController: NavigationController
notesController: NotesController
linkingController: LinkingController
historyModalController: HistoryModalController
selectionController: SelectedItemsController
onClickPreprocessing?: () => Promise<void>
}
@@ -22,6 +24,7 @@ const NotesOptionsPanel = ({
notesController,
linkingController,
historyModalController,
selectionController,
onClickPreprocessing,
}: Props) => {
const [isOpen, setIsOpen] = useState(false)
@@ -58,6 +61,7 @@ const NotesOptionsPanel = ({
notesController={notesController}
linkingController={linkingController}
historyModalController={historyModalController}
selectionController={selectionController}
requestDisableClickOutside={handleDisableClickOutsideRequest}
closeMenu={toggleMenu}
/>

View File

@@ -3,6 +3,7 @@ import { NavigationController } from '@/Controllers/Navigation/NavigationControl
import { NotesController } from '@/Controllers/NotesController/NotesController'
import { LinkingController } from '@/Controllers/LinkingController'
import { SNNote } from '@standardnotes/snjs'
import { SelectedItemsController } from '@/Controllers/SelectedItemsController'
export type NotesOptionsProps = {
notes: SNNote[]
@@ -10,6 +11,7 @@ export type NotesOptionsProps = {
notesController: NotesController
linkingController: LinkingController
historyModalController: HistoryModalController
selectionController: SelectedItemsController
requestDisableClickOutside?: (disabled: boolean) => void
closeMenu: () => void
}