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.

fix showFolderIcon implementation

Steven Tey59c827c40655
diff --git a/apps/web/lib/swr/use-current-folder-id.ts b/apps/web/lib/swr/use-current-folder-id.ts
index bbb13eaa69..15433d2125 100644
--- a/apps/web/lib/swr/use-current-folder-id.ts
+++ b/apps/web/lib/swr/use-current-folder-id.ts
@@ -1,6 +1,8 @@
import { useSearchParams } from "next/navigation";
import useWorkspace from "./use-workspace";
+// get the current folder id from the search params or the user's default folder
+// normalize the folder id to null if it is "unsorted"
export default function useCurrentFolderId() {
const { defaultFolderId } = useWorkspace();
const searchParams = useSearchParams();
diff --git a/apps/web/ui/links/link-card.tsx b/apps/web/ui/links/link-card.tsx
index f97958ce8d..67ac02782a 100644
--- a/apps/web/ui/links/link-card.tsx
+++ b/apps/web/ui/links/link-card.tsx
@@ -52,17 +52,18 @@ const LinkCardInner = memo(({ link }: { link: ResponseLink }) => {
const ref = useRef<HTMLDivElement>(null);
const router = useRouter();
- const { folderId: selectedFolderId } = useCurrentFolderId();
- const { slug, defaultFolderId } = useWorkspace();
+ const { folderId: currentFolderId } = useCurrentFolderId();
+ const { slug } = useWorkspace();
const { queryParams } = useRouterStuff();
+ // only show the folder icon if:
+ // - loading is complete
+ // - the link has a folder id AND the currentFolderId is not the same as the link's folder id
const showFolderIcon = useMemo(() => {
return Boolean(
- !loading &&
- link.folderId &&
- ![defaultFolderId, selectedFolderId].includes(link.folderId),
+ !loading && link.folderId && currentFolderId !== link.folderId,
);
- }, [loading, link.folderId, defaultFolderId, selectedFolderId]);
+ }, [loading, link.folderId, currentFolderId]);
const { folder } = useFolder({
folderId: link.folderId,
diff --git a/apps/web/ui/links/link-title-column.tsx b/apps/web/ui/links/link-title-column.tsx
index f29fa5ce42..f6d52612d5 100644
--- a/apps/web/ui/links/link-title-column.tsx
+++ b/apps/web/ui/links/link-title-column.tsx
@@ -88,10 +88,7 @@ export function LinkTitleColumn({ link }: { link: ResponseLink }) {
const showFolderIcon = useMemo(() => {
return Boolean(
- !loading &&
- link.folderId &&
- currentFolderId &&
- currentFolderId.includes(link.folderId),
+ !loading && link.folderId && currentFolderId !== link.folderId,
);
}, [loading, link.folderId, currentFolderId]);