mirror of
https://github.com/omnivore-app/omnivore.git
synced 2026-03-11 08:54:26 +00:00
Fix moveToFolder response handling
This commit is contained in:
parent
b6e19106b1
commit
8819ca1d05
2 changed files with 21 additions and 8 deletions
|
|
@ -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[]
|
||||
|
|
|
|||
Loading…
Reference in a new issue