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.

526 B
Raw Blame
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();
  let folderId = searchParams.get("folderId") ?? defaultFolderId ?? null;

  if (folderId === "unsorted") {
    folderId = null;
  }

  return { folderId };
}