From 0a459a20c4b769e1079e545f06b18ae4acdd800b Mon Sep 17 00:00:00 2001 From: Jackson Harper Date: Fri, 25 Mar 2022 10:35:19 -0700 Subject: [PATCH] Show success/error toasts for archiving and removing --- .../queries/useGetLibraryItemsQuery.tsx | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/packages/web/lib/networking/queries/useGetLibraryItemsQuery.tsx b/packages/web/lib/networking/queries/useGetLibraryItemsQuery.tsx index 64cf8d78d..70a66ca71 100644 --- a/packages/web/lib/networking/queries/useGetLibraryItemsQuery.tsx +++ b/packages/web/lib/networking/queries/useGetLibraryItemsQuery.tsx @@ -7,6 +7,7 @@ import { setLinkArchivedMutation } from '../mutations/setLinkArchivedMutation' import { deleteLinkMutation } from '../mutations/deleteLinkMutation' import { articleReadingProgressMutation } from '../mutations/articleReadingProgressMutation' import { Label } from './useGetLabelsQuery' +import { showErrorToast, showSuccessToast } from '../../toastHelpers' export type LibraryItemsQueryInput = { limit: number @@ -206,6 +207,12 @@ export function useGetLibraryItemsQuery({ setLinkArchivedMutation({ linkId: item.node.id, archived: true, + }).then((res) => { + if (res) { + showSuccessToast('Link archived', { position: 'bottom-right' }) + } else { + showErrorToast('Error archiving link', { position: 'bottom-right' }) + } }) break @@ -225,11 +232,24 @@ export function useGetLibraryItemsQuery({ setLinkArchivedMutation({ linkId: item.node.id, archived: false, + }).then((res) => { + if (res) { + showSuccessToast('Link unarchived', { position: 'bottom-right' }) + } else { + showErrorToast('Error unarchiving link', { position: 'bottom-right' }) + } }) break case 'delete': updateData(undefined) deleteLinkMutation(item.node.id) + .then((res) => { + if (res) { + showSuccessToast('Link removed', { position: 'bottom-right' }) + } else { + showErrorToast('Error removing link', { position: 'bottom-right' }) + } + }) break case 'mark-read': updateData({