Fix moveToFolder response handling
This commit is contained in:
@ -401,7 +401,8 @@ export function LibraryContainer(props: LibraryContainerProps): JSX.Element {
|
||||
linkId: item.node.id,
|
||||
archived: action == 'archive',
|
||||
})
|
||||
} catch {
|
||||
} catch (err) {
|
||||
console.log('Error setting archive state: ', err)
|
||||
showErrorToast(`Error ${action}ing item`, {
|
||||
position: 'bottom-right',
|
||||
})
|
||||
@ -414,7 +415,8 @@ export function LibraryContainer(props: LibraryContainerProps): JSX.Element {
|
||||
case 'delete':
|
||||
try {
|
||||
await deleteItem.mutateAsync(item.node.id)
|
||||
} catch {
|
||||
} catch (err) {
|
||||
console.log('Error deleting item: ', err)
|
||||
showErrorToast(`Error deleting item`, {
|
||||
position: 'bottom-right',
|
||||
})
|
||||
@ -445,7 +447,8 @@ export function LibraryContainer(props: LibraryContainerProps): JSX.Element {
|
||||
force: true,
|
||||
...values,
|
||||
})
|
||||
} catch {
|
||||
} catch (err) {
|
||||
console.log('Error marking item: ', err)
|
||||
showErrorToast(`Error marking as ${desc}`, {
|
||||
position: 'bottom-right',
|
||||
})
|
||||
@ -458,7 +461,8 @@ export function LibraryContainer(props: LibraryContainerProps): JSX.Element {
|
||||
itemId: item.node.id,
|
||||
folder: 'inbox',
|
||||
})
|
||||
} catch {
|
||||
} catch (err) {
|
||||
console.log('Error moving item: ', err)
|
||||
showErrorToast(`Error moving item`, {
|
||||
position: 'bottom-right',
|
||||
})
|
||||
|
||||
@ -275,11 +275,11 @@ export const useMoveItemToFolder = () => {
|
||||
const result = (await gqlFetcher(GQL_MOVE_ITEM_TO_FOLDER, {
|
||||
id: variables.itemId,
|
||||
folder: variables.folder,
|
||||
})) as UpdateLibraryItemData
|
||||
if (result.updatePage.errorCodes?.length) {
|
||||
throw new Error(result.updatePage.errorCodes[0])
|
||||
})) as MoveToFolderData
|
||||
if (result.moveToFolder.errorCodes?.length) {
|
||||
throw new Error(result.moveToFolder.errorCodes[0])
|
||||
}
|
||||
return result.updatePage
|
||||
return result.moveToFolder
|
||||
}
|
||||
return useMutation({
|
||||
mutationFn: restoreItem,
|
||||
@ -402,6 +402,15 @@ export type ArticleAttributes = {
|
||||
recommendations?: Recommendation[]
|
||||
}
|
||||
|
||||
type MoveToFolderData = {
|
||||
moveToFolder: MoveToFolderResult
|
||||
}
|
||||
|
||||
type MoveToFolderResult = {
|
||||
success?: boolean
|
||||
errorCodes?: string[]
|
||||
}
|
||||
|
||||
type ArticleResult = {
|
||||
article?: ArticleAttributes
|
||||
errorCodes?: string[]
|
||||
|
||||
Reference in New Issue
Block a user