Skip to content

armgit / dub

Public Imported from GitHub
0

The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.

Deselect hidden links

Tim Wilson3cb10ac214d5
diff --git a/apps/web/ui/links/link-selection-provider.tsx b/apps/web/ui/links/link-selection-provider.tsx
index 705ce9f607..af68a36436 100644
--- a/apps/web/ui/links/link-selection-provider.tsx
+++ b/apps/web/ui/links/link-selection-provider.tsx
@@ -3,6 +3,7 @@ import {
SetStateAction,
createContext,
useContext,
+ useEffect,
useState,
} from "react";
import { ResponseLink } from "./links-container";
@@ -28,6 +29,12 @@ export function LinkSelectionProvider({
null,
);
+ useEffect(() => {
+ setSelectedLinkIds((prev) =>
+ links ? prev.filter((id) => links.find((l) => l.id === id)) : [],
+ );
+ }, [links]);
+
const handleLinkSelection = (linkId: string, e: React.MouseEvent) => {
if (e.shiftKey && lastSelectedLinkId && links) {
const lastSelectedIndex = links.findIndex(
diff --git a/apps/web/ui/links/links-toolbar.tsx b/apps/web/ui/links/links-toolbar.tsx
index 980da59073..3b70e58776 100644
--- a/apps/web/ui/links/links-toolbar.tsx
+++ b/apps/web/ui/links/links-toolbar.tsx
@@ -29,7 +29,6 @@ export const LinksToolbar = ({
const { setShowArchiveLinkModal, ArchiveLinkModal } = useArchiveLinkModal({
props: selectedLinks,
- onSuccess: () => setSelectedLinkIds([]),
});
const bulkActions = [
diff --git a/apps/web/ui/modals/archive-link-modal.tsx b/apps/web/ui/modals/archive-link-modal.tsx
index db181cb204..df2bee9754 100644
--- a/apps/web/ui/modals/archive-link-modal.tsx
+++ b/apps/web/ui/modals/archive-link-modal.tsx
@@ -36,7 +36,6 @@ type ArchiveLinkModalProps = {
showArchiveLinkModal: boolean;
setShowArchiveLinkModal: Dispatch<SetStateAction<boolean>>;
links: LinkProps[];
- onSuccess?: () => void;
};
function ArchiveLinkModal(props: ArchiveLinkModalProps) {
@@ -53,7 +52,6 @@ function ArchiveLinkModal(props: ArchiveLinkModalProps) {
function ArchiveLinkModalInner({
setShowArchiveLinkModal,
links,
- onSuccess,
}: ArchiveLinkModalProps) {
const toastWithUndo = useToastWithUndo();
@@ -63,14 +61,6 @@ function ArchiveLinkModalInner({
const { id: workspaceId } = useWorkspace();
const [archiving, setArchiving] = useState(false);
- // const shortlink = useMemo(() => {
- // return linkConstructor({
- // key,
- // domain,
- // pretty: true,
- // });
- // }, [key, domain]);
-
const handleArchiveRequest = async (event: MouseEvent<HTMLButtonElement>) => {
event.preventDefault();
@@ -96,7 +86,6 @@ function ArchiveLinkModalInner({
undo: undoAction,
duration: 5000,
});
- onSuccess?.();
};
const undoAction = () => {
@@ -162,10 +151,8 @@ function ArchiveLinkModalInner({
export function useArchiveLinkModal({
props,
- onSuccess,
}: {
props: LinkProps | LinkProps[];
- onSuccess?: () => void;
}) {
const [showArchiveLinkModal, setShowArchiveLinkModal] = useState(false);
@@ -175,7 +162,6 @@ export function useArchiveLinkModal({
showArchiveLinkModal={showArchiveLinkModal}
setShowArchiveLinkModal={setShowArchiveLinkModal}
links={Array.isArray(props) ? props : [props]}
- onSuccess={onSuccess}
/>
) : null;
}, [showArchiveLinkModal, setShowArchiveLinkModal]);