mirror of
https://github.com/get-drexa/drive.git
synced 2026-02-02 16:31:17 +00:00
fix: update dir content query data on create dir
This commit is contained in:
@@ -81,8 +81,6 @@ export const directoryContentQueryAtom = atomFamily((directoryId: string) =>
|
|||||||
}),
|
}),
|
||||||
)
|
)
|
||||||
|
|
||||||
// Directory Mutations
|
|
||||||
|
|
||||||
export const createDirectoryMutationAtom = atom((get) => {
|
export const createDirectoryMutationAtom = atom((get) => {
|
||||||
const account = get(currentAccountAtom)
|
const account = get(currentAccountAtom)
|
||||||
return mutationOptions({
|
return mutationOptions({
|
||||||
@@ -105,6 +103,13 @@ export const createDirectoryMutationAtom = atom((get) => {
|
|||||||
get(directoryInfoQueryAtom(data.id)).queryKey,
|
get(directoryInfoQueryAtom(data.id)).queryKey,
|
||||||
data,
|
data,
|
||||||
)
|
)
|
||||||
|
const parent = data.path.at(-2)
|
||||||
|
if (parent) {
|
||||||
|
client.setQueryData(
|
||||||
|
get(directoryContentQueryAtom(parent.id)).queryKey,
|
||||||
|
(prev) => (prev ? [...prev, data] : [data]),
|
||||||
|
)
|
||||||
|
}
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user