mirror of
https://github.com/get-drexa/drive.git
synced 2026-02-02 13:41:18 +00:00
fix: invalidate dir content query after uploads
This commit is contained in:
@@ -28,8 +28,9 @@ import {
|
|||||||
TooltipContent,
|
TooltipContent,
|
||||||
TooltipTrigger,
|
TooltipTrigger,
|
||||||
} from "@/components/ui/tooltip"
|
} from "@/components/ui/tooltip"
|
||||||
import type { DirectoryInfoWithPath } from "@/vfs/vfs"
|
|
||||||
import { formatError } from "@/lib/error"
|
import { formatError } from "@/lib/error"
|
||||||
|
import { directoryContentQueryAtom } from "@/vfs/api"
|
||||||
|
import type { DirectoryInfoWithPath } from "@/vfs/vfs"
|
||||||
import { currentAccountAtom } from "../account/account"
|
import { currentAccountAtom } from "../account/account"
|
||||||
import {
|
import {
|
||||||
clearAllFileUploadStatusesAtom,
|
clearAllFileUploadStatusesAtom,
|
||||||
@@ -106,7 +107,7 @@ function useUploadFilesAtom({
|
|||||||
)
|
)
|
||||||
return await Promise.allSettled(promises)
|
return await Promise.allSettled(promises)
|
||||||
},
|
},
|
||||||
onSuccess: (results, files) => {
|
onSuccess: (results, files, _result, { client }) => {
|
||||||
const remainingPickedFiles: PickedFile[] = []
|
const remainingPickedFiles: PickedFile[] = []
|
||||||
results.forEach((result, i) => {
|
results.forEach((result, i) => {
|
||||||
// biome-ignore lint/style/noNonNullAssertion: results lenght must match input files array length
|
// biome-ignore lint/style/noNonNullAssertion: results lenght must match input files array length
|
||||||
@@ -129,13 +130,19 @@ function useUploadFilesAtom({
|
|||||||
break
|
break
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
// setPickedFiles(remainingPickedFiles)
|
|
||||||
|
|
||||||
if (remainingPickedFiles.length === 0) {
|
if (remainingPickedFiles.length === 0) {
|
||||||
toast.success("All files uploaded successfully")
|
toast.success("All files uploaded successfully")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
client.invalidateQueries(
|
||||||
|
store.get(
|
||||||
|
directoryContentQueryAtom(targetDirectory.id),
|
||||||
|
),
|
||||||
|
)
|
||||||
},
|
},
|
||||||
onError: (error) => {
|
onError: (error) => {
|
||||||
|
console.error(error)
|
||||||
toast.error(formatError(error))
|
toast.error(formatError(error))
|
||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
|
|||||||
Reference in New Issue
Block a user