Skip to content

armgit / Cap

Public Imported from GitHub
0

Open source Loom alternative. Beautiful, shareable screen recordings.

dont show the space if the member hasnt been added (#646)

Ameer Al Ashhab5c0cd1bb4fa7
diff --git a/apps/web/app/dashboard/dashboard-data.ts b/apps/web/app/dashboard/dashboard-data.ts
index c9bbb3574..1bc1c59ae 100644
--- a/apps/web/app/dashboard/dashboard-data.ts
+++ b/apps/web/app/dashboard/dashboard-data.ts
@@ -7,8 +7,9 @@ import {
users,
spaces,
sharedVideos,
+ spaceMembers,
} from "@cap/database/schema";
-import { count, eq, inArray, or, sql } from "drizzle-orm";
+import { and, count, eq, inArray, or, sql } from "drizzle-orm";
export type Organization = {
organization: typeof organizations.$inferSelect;
@@ -104,7 +105,21 @@ export async function getDashboardData(user: typeof userSelectProps) {
)`,
})
.from(spaces)
- .where(eq(spaces.organizationId, activeOrganizationId));
+ .leftJoin(spaceMembers, eq(spaces.id, spaceMembers.spaceId))
+ .where(
+ and(
+ eq(spaces.organizationId, activeOrganizationId),
+ or(
+ // User is the space creator
+ eq(spaces.createdById, user.id),
+ // User is a member of the space
+ eq(spaceMembers.userId, user.id),
+ // Space is public within the organization
+ eq(spaces.privacy, "Public")
+ )
+ )
+ )
+ .groupBy(spaces.id);
// Add a single 'All spaces' entry for the active organization
const activeOrgInfo = organizationsWithMembers.find(
diff --git a/apps/web/app/dashboard/spaces/[spaceId]/components/AddVideosDialogBase.tsx b/apps/web/app/dashboard/spaces/[spaceId]/components/AddVideosDialogBase.tsx
index 415fbb8bb..6fec5f026 100644
--- a/apps/web/app/dashboard/spaces/[spaceId]/components/AddVideosDialogBase.tsx
+++ b/apps/web/app/dashboard/spaces/[spaceId]/components/AddVideosDialogBase.tsx
@@ -140,7 +140,7 @@ const AddVideosDialogBase: React.FC<AddVideosDialogBaseProps> = ({
return (
<Dialog open={open} onOpenChange={(open) => !open && onClose()}>
- <DialogContent className="p-0 w-full max-w-2xl rounded-xl border bg-gray-2 border-gray-4 max-h-[90vh] sm:max-h-[85vh] flex flex-col">
+ <DialogContent className="p-0 w-full max-w-2xl rounded-xl border bg-gray-2 border-gray-4 max-h-[600px] flex flex-col">
<DialogHeader
icon={<FontAwesomeIcon icon={faVideo} />}
description={