Skip to content

Commit

Permalink
Don't attempt to load a parent if we don't have a parent id
Browse files Browse the repository at this point in the history
  • Loading branch information
benmerckx committed Jan 20, 2025
1 parent 793081d commit 22a54fa
Showing 1 changed file with 16 additions and 14 deletions.
30 changes: 16 additions & 14 deletions src/dashboard/hook/UseUploads.ts
Original file line number Diff line number Diff line change
Expand Up @@ -171,20 +171,22 @@ export function useUploads(onSelect?: (entry: EntryRow) => void) {
const entryId = upload.info?.entryId ?? createId()
const {parentId} = upload.to
const buffer = await upload.file.arrayBuffer()
const parent = await graph.first({
select: {
level: Entry.level,
entryId: Entry.id,
url: Entry.url,
path: Entry.path,
parentPaths: {
edge: 'parents',
select: Entry.path
}
},
id: parentId,
status: 'preferPublished'
})
const parent =
parentId &&
(await graph.first({
select: {
level: Entry.level,
entryId: Entry.id,
url: Entry.url,
path: Entry.path,
parentPaths: {
edge: 'parents',
select: Entry.path
}
},
id: parentId,
status: 'preferPublished'
}))

const extensionOriginal = extname(upload.file.name)
const extension = extensionOriginal.toLowerCase()
Expand Down

0 comments on commit 22a54fa

Please sign in to comment.