refactor: use correct endpoint when uploading file to shared vault note
This commit is contained in:
@@ -3,7 +3,7 @@ import { usePremiumModal } from '@/Hooks/usePremiumModal'
|
||||
import { classNames } from '@standardnotes/utils'
|
||||
import { isHandlingFileDrag } from '@/Utils/DragTypeCheck'
|
||||
import { StreamingFileReader } from '@standardnotes/filepicker'
|
||||
import { FileItem } from '@standardnotes/snjs'
|
||||
import { FileItem, SNNote } from '@standardnotes/snjs'
|
||||
import { useMemo, useState, createContext, ReactNode, useRef, useCallback, useEffect, useContext, memo } from 'react'
|
||||
import Portal from './Portal/Portal'
|
||||
import { ElementIds } from '@/Constants/ElementIDs'
|
||||
@@ -11,6 +11,7 @@ import { ElementIds } from '@/Constants/ElementIDs'
|
||||
type FileDragTargetData = {
|
||||
tooltipText: string
|
||||
callback: (files: FileItem) => void
|
||||
note?: SNNote
|
||||
}
|
||||
|
||||
type FileDnDContextData = {
|
||||
@@ -200,15 +201,17 @@ const FileDragNDropProvider = ({ application, children }: Props) => {
|
||||
return
|
||||
}
|
||||
|
||||
const uploadedFile = await application.filesController.uploadNewFile(fileOrHandle)
|
||||
const dragTarget = closestDragTarget ? dragTargets.current.get(closestDragTarget) : undefined
|
||||
|
||||
const uploadedFile = await application.filesController.uploadNewFile(fileOrHandle, {
|
||||
note: dragTarget?.note,
|
||||
})
|
||||
|
||||
if (!uploadedFile) {
|
||||
return
|
||||
}
|
||||
|
||||
if (closestDragTarget && dragTargets.current.has(closestDragTarget)) {
|
||||
dragTargets.current.get(closestDragTarget)?.callback(uploadedFile)
|
||||
}
|
||||
dragTarget?.callback(uploadedFile)
|
||||
})
|
||||
|
||||
dragCounter.current = 0
|
||||
|
||||
@@ -9,7 +9,7 @@ import Icon from '../Icon/Icon'
|
||||
import DecoratedInput from '../Input/DecoratedInput'
|
||||
import LinkedItemSearchResults from './LinkedItemSearchResults'
|
||||
import { LinkedItemsSectionItem } from './LinkedItemsSectionItem'
|
||||
import { DecryptedItem } from '@standardnotes/snjs'
|
||||
import { DecryptedItem, SNNote } from '@standardnotes/snjs'
|
||||
import { useItemLinks } from '@/Hooks/useItemLinks'
|
||||
import { mergeRefs } from '@/Hooks/mergeRefs'
|
||||
|
||||
@@ -41,7 +41,7 @@ const LinkedItemsPanel = ({ item }: { item: DecryptedItem }) => {
|
||||
return
|
||||
}
|
||||
|
||||
void application.filesController.selectAndUploadNewFiles((file) => {
|
||||
void application.filesController.selectAndUploadNewFiles(item instanceof SNNote ? item : undefined, (file) => {
|
||||
void linkItems(item, file)
|
||||
})
|
||||
}
|
||||
|
||||
@@ -29,6 +29,7 @@ const NoteViewFileDropTarget = ({ note, linkingController, noteViewElement, file
|
||||
})
|
||||
filesController.notifyObserversOfUploadedFileLinkingToCurrentNote(uploadedFile.uuid)
|
||||
},
|
||||
note,
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user