diff --git a/packages/web/components/patterns/LibraryCards/CardTypes.tsx b/packages/web/components/patterns/LibraryCards/CardTypes.tsx index fbf713688..6c76f16c1 100644 --- a/packages/web/components/patterns/LibraryCards/CardTypes.tsx +++ b/packages/web/components/patterns/LibraryCards/CardTypes.tsx @@ -16,6 +16,7 @@ export type LinkedItemCardAction = | 'open-notebook' | 'unsubscribe' | 'update-item' + | 'move-to-inbox' export type LinkedItemCardProps = { item: LibraryItemNode diff --git a/packages/web/components/patterns/LibraryCards/LibraryHoverActions.tsx b/packages/web/components/patterns/LibraryCards/LibraryHoverActions.tsx index 28ad8382b..803d3d38f 100644 --- a/packages/web/components/patterns/LibraryCards/LibraryHoverActions.tsx +++ b/packages/web/components/patterns/LibraryCards/LibraryHoverActions.tsx @@ -13,7 +13,6 @@ import { TrashIcon } from '../../elements/icons/TrashIcon' import { LabelIcon } from '../../elements/icons/LabelIcon' import { UnarchiveIcon } from '../../elements/icons/UnarchiveIcon' import { BrowserIcon } from '../../elements/icons/BrowserIcon' -import { LibraryIcon } from '../../elements/icons/LibraryIcon' import useLibraryItemActions from '../../../lib/hooks/useLibraryItemActions' import { MoveToInboxIcon } from '../../elements/icons/MoveToInboxIcon' @@ -82,9 +81,7 @@ export const LibraryHoverActions = (props: LibraryHoverActionsProps) => { onClick={async (event) => { event.preventDefault() event.stopPropagation() - if (await moveItem(props.item.id)) { - props.handleAction('update-item') - } + props.handleAction('move-to-inbox') }} > { + if (res) { + showSuccessToast('Link moved', { position: 'bottom-right' }) + } else { + showErrorToast('Error moving link', { position: 'bottom-right' }) + } + }) + + mutate() + break case 'archive': - console.log('setting item archived') updateData({ cursor: item.cursor, node: { @@ -341,17 +356,13 @@ export function useGetLibraryItemsQuery( break case 'unarchive': - if (/in:all/.test(query)) { - updateData({ - cursor: item.cursor, - node: { - ...item.node, - isArchived: false, - }, - }) - } else { - updateData(undefined) - } + updateData({ + cursor: item.cursor, + node: { + ...item.node, + isArchived: false, + }, + }) setLinkArchivedMutation({ linkId: item.node.id, @@ -365,9 +376,16 @@ export function useGetLibraryItemsQuery( }) } }) + mutate() break case 'delete': - updateData(undefined) + updateData({ + cursor: item.cursor, + node: { + ...item.node, + state: State.DELETED, + }, + }) const pageId = item.node.id deleteLinkMutation(pageId).then((res) => { diff --git a/packages/web/pages/l/[section].tsx b/packages/web/pages/l/[section].tsx index db943eacc..e6736f2dc 100644 --- a/packages/web/pages/l/[section].tsx +++ b/packages/web/pages/l/[section].tsx @@ -74,7 +74,14 @@ export default function Home(): JSX.Element { return ( item.state != 'DELETED' && item.isArchived} + filterFunc={(item) => { + console.log( + 'running archive filter: ', + item.title, + item.isArchived + ) + return item.state != 'DELETED' && item.isArchived + }} showNavigationMenu={showNavigationMenu} /> )