diff --git a/apps/web/components/add-document/index.tsx b/apps/web/components/add-document/index.tsx index 2310c956..cf875329 100644 --- a/apps/web/components/add-document/index.tsx +++ b/apps/web/components/add-document/index.tsx @@ -380,40 +380,42 @@ export function AddDocument({
- {activeTab === "note" && ( - - )} - {activeTab === "link" && ( - - )} - {activeTab === "file" && ( - - )} - {activeTab === "connect" && ( - - )} +
+ {activeTab === "note" && ( + + )} + {activeTab === "link" && ( + + )} + {activeTab === "file" && ( + + )} + {activeTab === "connect" && ( + + )} +
@@ -424,6 +426,7 @@ export function AddDocument({ setLocalSelectedProject(projects[0] ?? localSelectedProject) } variant="insideOut" + singleSelect /> )}
void + onCreated?: (containerTag: string) => void }) { const [spaceName, setSpaceName] = useState("") const [emoji, setEmoji] = useState("📁") @@ -87,8 +89,11 @@ export function AddSpaceModal({ createProjectMutation.mutate( { name: trimmedName, emoji: emoji || undefined }, { - onSuccess: () => { + onSuccess: (data) => { analytics.spaceCreated() + if (data?.containerTag) { + onCreated?.(data.containerTag) + } handleClose() }, }, diff --git a/apps/web/components/select-spaces-modal.tsx b/apps/web/components/select-spaces-modal.tsx index ad49a4ce..895bbf6d 100644 --- a/apps/web/components/select-spaces-modal.tsx +++ b/apps/web/components/select-spaces-modal.tsx @@ -16,6 +16,7 @@ interface SelectSpacesModalProps { selectedProjects: string[] onApply: (selected: string[]) => void projects: ContainerTagListType[] + singleSelect?: boolean } export function SelectSpacesModal({ @@ -24,6 +25,7 @@ export function SelectSpacesModal({ selectedProjects, onApply, projects, + singleSelect = false, }: SelectSpacesModalProps) { const [searchQuery, setSearchQuery] = useState("") const [localSelection, setLocalSelection] = @@ -44,6 +46,10 @@ export function SelectSpacesModal({ } const handleToggle = (containerTag: string) => { + if (singleSelect) { + setLocalSelection([containerTag]) + return + } setLocalSelection((prev) => { if (prev.includes(containerTag)) { return prev.filter((tag) => tag !== containerTag) @@ -117,10 +123,12 @@ export function SelectSpacesModal({ dmSans125ClassName(), )} > - Select Spaces + Select Space{!singleSelect && "s"}

- Choose one or more spaces to filter your memories + {singleSelect + ? "Choose a space for your memory" + : "Choose one or more spaces to filter your memories"}

-
- {isSelected && } -
+ {singleSelect ? ( +
+ {isSelected && ( +
+ )} +
+ ) : ( +
+ {isSelected && } +
+ )} {project.emoji || "📁"} {project.name ?? project.containerTag} @@ -195,9 +216,13 @@ export function SelectSpacesModal({

- {localSelection.length === 0 - ? "No spaces selected (showing all)" - : `${localSelection.length} space${localSelection.length > 1 ? "s" : ""} selected`} + {singleSelect + ? localSelection.length === 0 + ? "No space selected" + : "1 space selected" + : localSelection.length === 0 + ? "No spaces selected (showing all)" + : `${localSelection.length} space${localSelection.length > 1 ? "s" : ""} selected`}

{showNewSpace && ( @@ -386,6 +392,7 @@ export function SpaceSelector({ setShowCreateDialog(false)} + onCreated={(containerTag) => onValueChange([containerTag])} /> { toast.success("Project created successfully!") queryClient.invalidateQueries({ queryKey: ["projects"] }) + queryClient.invalidateQueries({ queryKey: ["container-tags"] }) if (data?.containerTag) { setSelectedProjects([data.containerTag]) @@ -63,14 +64,12 @@ export function useProjectMutations() { }, onSuccess: (_, variables) => { toast.success("Project deleted successfully") - queryClient.invalidateQueries({ queryKey: ["projects"] }) - queryClient.invalidateQueries({ queryKey: ["container-tags"] }) - const allProjects = - queryClient.getQueryData(["projects"]) || [] - const deletedProject = allProjects.find( - (p) => p.id === variables.projectId, - ) + const allTags = + queryClient.getQueryData(["container-tags"]) || + [] + const deletedProject = allTags.find((p) => p.id === variables.projectId) + if ( deletedProject?.containerTag && selectedProjects.includes(deletedProject.containerTag) @@ -79,6 +78,9 @@ export function useProjectMutations() { selectedProjects.filter((tag) => tag !== deletedProject.containerTag), ) } + + queryClient.invalidateQueries({ queryKey: ["projects"] }) + queryClient.invalidateQueries({ queryKey: ["container-tags"] }) }, onError: (error) => { toast.error("Failed to delete project", {