Call mutate after uploading an item completes

This commit is contained in:
Jackson Harper 2022-11-14 17:05:38 +08:00
parent ad391fb4e6
commit b5a1d8fb9f
3 changed files with 6 additions and 2 deletions

View file

@ -127,7 +127,7 @@ export function HomeFeedContainer(): JSX.Element {
})
)
const { itemsPages, size, setSize, isValidating, performActionOnItem } =
const { itemsPages, size, setSize, isValidating, performActionOnItem, mutate } =
useGetLibraryItemsQuery(queryInputs)
useEffect(() => {
@ -560,6 +560,7 @@ export function HomeFeedContainer(): JSX.Element {
<HomeFeedGrid
items={libraryItems}
actionHandler={handleCardAction}
reloadItems={mutate}
searchTerm={queryInputs.searchQuery}
gridContainerRef={gridContainerRef}
applySearchQuery={(searchQuery: string) => {
@ -613,6 +614,7 @@ export function HomeFeedContainer(): JSX.Element {
type HomeFeedContentProps = {
items: LibraryItem[]
searchTerm?: string
reloadItems: () => void
gridContainerRef: React.RefObject<HTMLDivElement>
applySearchQuery: (searchQuery: string) => void
hasMore: boolean
@ -736,6 +738,7 @@ function HomeFeedGrid(props: HomeFeedContentProps): JSX.Element {
}
setUploadingFiles([])
props.reloadItems()
}
return (

View file

@ -51,6 +51,5 @@ export async function uploadFileRequestMutation(
if (error) {
throw error
}
console.log("RESPONSE DATA: ", data)
return output?.uploadFileRequest
}

View file

@ -27,6 +27,7 @@ type LibraryItemsQueryResponse = {
size: number | ((_size: number) => number)
) => Promise<unknown[] | undefined>
performActionOnItem: (action: LibraryItemAction, item: LibraryItem) => void
mutate: () => void
}
type LibraryItemAction =
@ -352,5 +353,6 @@ export function useGetLibraryItemsQuery({
performActionOnItem,
size,
setSize,
mutate
}
}