fix: Files uploaded to a protected Super note will also be marked as protected

This commit is contained in:
Aman Harwara
2023-03-30 12:19:15 +05:30
parent 08a20e25b4
commit 09fd65903b
3 changed files with 15 additions and 4 deletions

View File

@@ -2,6 +2,7 @@ import { FilesController } from '@/Controllers/FilesController'
import { LinkingController } from '@/Controllers/LinkingController'
import { SNNote } from '@standardnotes/snjs'
import { useEffect } from 'react'
import { useApplication } from '../ApplicationProvider'
import { useFileDragNDrop } from '../FileDragNDropProvider'
type Props = {
@@ -12,6 +13,7 @@ type Props = {
}
const NoteViewFileDropTarget = ({ note, linkingController, noteViewElement, filesController }: Props) => {
const application = useApplication()
const { isDraggingFiles, addDragTarget, removeDragTarget } = useFileDragNDrop()
useEffect(() => {
@@ -22,6 +24,9 @@ const NoteViewFileDropTarget = ({ note, linkingController, noteViewElement, file
tooltipText: 'Drop your files to upload and link them to the current note',
callback: async (uploadedFile) => {
await linkingController.linkItems(note, uploadedFile)
void application.mutator.changeAndSaveItem(uploadedFile, (mutator) => {
mutator.protected = note.protected
})
filesController.notifyObserversOfUploadedFileLinkingToCurrentNote(uploadedFile.uuid)
},
})
@@ -32,7 +37,7 @@ const NoteViewFileDropTarget = ({ note, linkingController, noteViewElement, file
removeDragTarget(target)
}
}
}, [addDragTarget, linkingController, note, noteViewElement, removeDragTarget, filesController])
}, [addDragTarget, linkingController, note, noteViewElement, removeDragTarget, filesController, application.mutator])
return isDraggingFiles ? (
// Required to block drag events to editor iframe