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.

Scope drafts to workspace

Tim Wilson9c0f04036b44
diff --git a/apps/web/ui/modals/link-builder/draft-controls.tsx b/apps/web/ui/modals/link-builder/draft-controls.tsx
index 8a9433799c..1370da49a6 100644
--- a/apps/web/ui/modals/link-builder/draft-controls.tsx
+++ b/apps/web/ui/modals/link-builder/draft-controls.tsx
@@ -28,12 +28,13 @@ export type DraftControlsHandle = {
type DraftControlsProps = {
props?: LinkWithTagsProps;
+ workspaceId: string;
};
export const DraftControls = forwardRef<
DraftControlsHandle,
DraftControlsProps
->(({ props }: DraftControlsProps, ref) => {
+>(({ props, workspaceId }: DraftControlsProps, ref) => {
const { isMobile } = useMediaQuery();
const {
@@ -54,6 +55,7 @@ export const DraftControls = forwardRef<
removeDraft,
} = useLinkDrafts({
linkId: props?.id,
+ workspaceId,
});
const drafts = useMemo(() => {
diff --git a/apps/web/ui/modals/link-builder/index.tsx b/apps/web/ui/modals/link-builder/index.tsx
index 82c51166fc..7e08d9fd30 100644
--- a/apps/web/ui/modals/link-builder/index.tsx
+++ b/apps/web/ui/modals/link-builder/index.tsx
@@ -333,7 +333,13 @@ function LinkBuilderInner({
</div>
{!homepageDemo && (
<div className="flex items-center gap-4">
- <DraftControls ref={draftControlsRef} props={props} />
+ {!homepageDemo && workspaceId && (
+ <DraftControls
+ ref={draftControlsRef}
+ props={props}
+ workspaceId={workspaceId}
+ />
+ )}
<button
type="button"
onClick={() => {
diff --git a/apps/web/ui/modals/link-builder/use-link-drafts.ts b/apps/web/ui/modals/link-builder/use-link-drafts.ts
index 03d49fe71d..55d9711f22 100644
--- a/apps/web/ui/modals/link-builder/use-link-drafts.ts
+++ b/apps/web/ui/modals/link-builder/use-link-drafts.ts
@@ -9,8 +9,17 @@ export type LinkDraft = {
link: Partial<LinkFormData>;
};
-export function useLinkDrafts({ linkId }: { linkId?: string } = {}) {
- const [drafts, setDrafts] = useLocalStorage<LinkDraft[]>("link-drafts", []);
+export function useLinkDrafts({
+ linkId,
+ workspaceId,
+}: {
+ linkId?: string;
+ workspaceId: string;
+}) {
+ const [drafts, setDrafts] = useLocalStorage<LinkDraft[]>(
+ `link-drafts:${workspaceId}`,
+ [],
+ );
// Removes drafts older than 1 week, limiting to 10 drafts
const removeOldDrafts = useCallback(() => {