Open source Loom alternative. Beautiful, shareable screen recordings.
Rust appcapcossloommacnextjsnextjs15open-sourceossreactrecordrustscreen-capturescreen-recorderscreenshotsolidjstauritauri-apptypescriptvite
fix: adding videos to "all" spaces (#811)
Ameer Al Ashhab19c56e3ba376
diff --git a/apps/desktop/src/routes/(window-chrome)/(main).tsx b/apps/desktop/src/routes/(window-chrome)/(main).tsxindex 6d1685bab..e1f8c808b 100644--- a/apps/desktop/src/routes/(window-chrome)/(main).tsx+++ b/apps/desktop/src/routes/(window-chrome)/(main).tsx@@ -431,7 +431,7 @@ function Page() {) : (<Buttondisabled={toggleRecording.isPending}- variant={isRecording() ? "destructive" : "blue"}+ variant="blue"size="md"onClick={() => toggleRecording.mutate()}class="flex flex-grow justify-center items-center"@@ -441,9 +441,9 @@ function Page() {) : (<>{rawOptions.mode === "instant" ? (- <IconCapInstant class="size-[0.8rem] mr-1.5" />+ <IconCapInstant class={cx("size-[0.8rem] mr-1.5", toggleRecording.isPending ? "opacity-50" : "opacity-100")} />) : (- <IconCapFilmCut class="size-[0.8rem] mr-2 -mt-[1.5px]" />+ <IconCapFilmCut class={cx("size-[0.8rem] mr-2 -mt-[1.5px]", toggleRecording.isPending ? "opacity-50" : "opacity-100")} />)}Start Recording</>diff --git a/apps/desktop/src/routes/editor/Header.tsx b/apps/desktop/src/routes/editor/Header.tsxindex dcf28760b..d83a8eb27 100644--- a/apps/desktop/src/routes/editor/Header.tsx+++ b/apps/desktop/src/routes/editor/Header.tsx@@ -179,7 +179,7 @@ export function Header() {</Show><Buttonvariant="lightdark"- class={cx("flex gap-1.5 justify-center h-[40px]")}+ class="flex gap-1.5 justify-center h-[40px] w-full max-w-[100px]"onClick={() => {trackEvent("export_button_clicked");if (exportState.type === "done") setExportState({ type: "idle" });diff --git a/apps/web/actions/organizations/add-videos.ts b/apps/web/actions/organizations/add-videos.tsindex 0da6957c4..6055245dc 100644--- a/apps/web/actions/organizations/add-videos.ts+++ b/apps/web/actions/organizations/add-videos.ts@@ -1,13 +1,21 @@"use server";import { getCurrentUser } from "@cap/database/auth/session";-import { sharedVideos, organizations, videos, organizationMembers } from "@cap/database/schema";+import {+ sharedVideos,+ organizations,+ videos,+ organizationMembers,+} from "@cap/database/schema";import { db } from "@cap/database";import { eq, and, inArray } from "drizzle-orm";import { nanoId } from "@cap/database/helpers";import { revalidatePath } from "next/cache";-export async function addVideosToOrganization(organizationId: string, videoIds: string[]) {+export async function addVideosToOrganization(+ organizationId: string,+ videoIds: string[]+) {try {const user = await getCurrentUser();@@ -47,7 +55,9 @@ export async function addVideosToOrganization(organizationId: string, videoIds:}if (!hasAccess) {- throw new Error("You don't have permission to add videos to this organization");+ throw new Error(+ "You don't have permission to add videos to this organization"+ );}const userVideos = await db()@@ -55,7 +65,7 @@ export async function addVideosToOrganization(organizationId: string, videoIds:.from(videos).where(and(eq(videos.ownerId, user.id), inArray(videos.id, videoIds)));- const validVideoIds = userVideos.map(v => v.id);+ const validVideoIds = userVideos.map((v) => v.id);if (validVideoIds.length === 0) {throw new Error("No valid videos found");@@ -64,19 +74,26 @@ export async function addVideosToOrganization(organizationId: string, videoIds:const existingSharedVideos = await db().select({ videoId: sharedVideos.videoId }).from(sharedVideos)- .where(and(- eq(sharedVideos.organizationId, organizationId),- inArray(sharedVideos.videoId, validVideoIds)- ));+ .where(+ and(+ eq(sharedVideos.organizationId, organizationId),+ inArray(sharedVideos.videoId, validVideoIds)+ )+ );- const existingVideoIds = existingSharedVideos.map(sv => sv.videoId);- const newVideoIds = validVideoIds.filter(id => !existingVideoIds.includes(id));+ const existingVideoIds = existingSharedVideos.map((sv) => sv.videoId);+ const newVideoIds = validVideoIds.filter(+ (id) => !existingVideoIds.includes(id)+ );if (newVideoIds.length === 0) {- return { success: true, message: "Videos already shared with organization" };+ return {+ success: true,+ message: "Videos already shared with organization",+ };}- const sharedVideoEntries = newVideoIds.map(videoId => ({+ const sharedVideoEntries = newVideoIds.map((videoId) => ({id: nanoId(),videoId,organizationId,@@ -85,18 +102,29 @@ export async function addVideosToOrganization(organizationId: string, videoIds:await db().insert(sharedVideos).values(sharedVideoEntries);+ // Clear folderId for videos added to organization so they appear in main view+ await db()+ .update(videos)+ .set({ folderId: null })+ .where(inArray(videos.id, newVideoIds));+revalidatePath(`/dashboard/spaces/${organizationId}`);revalidatePath("/dashboard/caps");- return {- success: true,- message: `${newVideoIds.length} video${newVideoIds.length === 1 ? '' : 's'} shared with organization`+ return {+ success: true,+ message: `${newVideoIds.length} video${+ newVideoIds.length === 1 ? "" : "s"+ } shared with organization`,};} catch (error) {console.error("Error adding videos to organization:", error);- return {- success: false,- error: error instanceof Error ? error.message : "Failed to add videos to organization"+ return {+ success: false,+ error:+ error instanceof Error+ ? error.message+ : "Failed to add videos to organization",};}-}\ No newline at end of file+}diff --git a/apps/web/actions/organizations/remove-videos.ts b/apps/web/actions/organizations/remove-videos.tsindex 7e50076e3..d49677fbf 100644--- a/apps/web/actions/organizations/remove-videos.ts+++ b/apps/web/actions/organizations/remove-videos.ts@@ -1,12 +1,21 @@"use server";import { getCurrentUser } from "@cap/database/auth/session";-import { sharedVideos, organizations, organizationMembers } from "@cap/database/schema";+import {+ sharedVideos,+ organizations,+ organizationMembers,+ folders,+ videos,+} from "@cap/database/schema";import { db } from "@cap/database";import { eq, and, inArray } from "drizzle-orm";import { revalidatePath } from "next/cache";-export async function removeVideosFromOrganization(organizationId: string, videoIds: string[]) {+export async function removeVideosFromOrganization(+ organizationId: string,+ videoIds: string[]+) {try {const user = await getCurrentUser();@@ -45,7 +54,9 @@ export async function removeVideosFromOrganization(organizationId: string, video}if (!hasAccess) {- throw new Error("You don't have permission to remove videos from this organization");+ throw new Error(+ "You don't have permission to remove videos from this organization"+ );}// Only allow removing videos that are currently shared with the organization@@ -59,10 +70,13 @@ export async function removeVideosFromOrganization(organizationId: string, video));- const existingVideoIds = existingSharedVideos.map(sv => sv.videoId);+ const existingVideoIds = existingSharedVideos.map((sv) => sv.videoId);if (existingVideoIds.length === 0) {- return { success: true, message: "No matching shared videos found in organization" };+ return {+ success: true,+ message: "No matching shared videos found in organization",+ };}await db()@@ -74,18 +88,44 @@ export async function removeVideosFromOrganization(organizationId: string, video));+ // Clear folderId for videos that are being removed from the organization and are currently in folders within that organization+ // First, get all folder IDs that belong to this organization+ const organizationFolders = await db()+ .select({ id: folders.id })+ .from(folders)+ .where(eq(folders.organizationId, organizationId));++ const organizationFolderIds = organizationFolders.map((f) => f.id);++ if (organizationFolderIds.length > 0) {+ await db()+ .update(videos)+ .set({ folderId: null })+ .where(+ and(+ inArray(videos.id, existingVideoIds),+ inArray(videos.folderId, organizationFolderIds)+ )+ );+ }+revalidatePath(`/dashboard/spaces/${organizationId}`);revalidatePath("/dashboard/caps");return {success: true,- message: `${existingVideoIds.length} video${existingVideoIds.length === 1 ? '' : 's'} removed from organization`+ message: `${existingVideoIds.length} video${+ existingVideoIds.length === 1 ? "" : "s"+ } removed from organization`,};} catch (error) {console.error("Error removing videos from organization:", error);return {success: false,- error: error instanceof Error ? error.message : "Failed to remove videos from organization"+ error:+ error instanceof Error+ ? error.message+ : "Failed to remove videos from organization",};}}diff --git a/apps/web/app/(org)/dashboard/caps/Caps.tsx b/apps/web/app/(org)/dashboard/caps/Caps.tsxindex 5881be2a1..4b42adc37 100644--- a/apps/web/app/(org)/dashboard/caps/Caps.tsx+++ b/apps/web/app/(org)/dashboard/caps/Caps.tsx@@ -28,11 +28,13 @@ export type VideoData = {createdAt: Date;totalComments: number;totalReactions: number;+ foldersData: FolderDataType[];sharedOrganizations: { id: string; name: string; iconUrl?: string }[];- sharedSpaces: {+ sharedSpaces?: {id: string;name: string;- iconUrl?: string;+ iconUrl: string;+ isOrg: boolean;organizationId: string;}[];ownerName: string;diff --git a/apps/web/app/(org)/dashboard/caps/page.tsx b/apps/web/app/(org)/dashboard/caps/page.tsxindex d5a014051..40d658294 100644--- a/apps/web/app/(org)/dashboard/caps/page.tsx+++ b/apps/web/app/(org)/dashboard/caps/page.tsx@@ -61,7 +61,7 @@ async function getSharedSpacesForVideos(videoIds: string[]) {if (!sharedSpacesMap[space.videoId]) {sharedSpacesMap[space.videoId] = [];}- sharedSpacesMap[space.videoId].push({+ sharedSpacesMap[space.videoId]?.push({id: space.id,name: space.name,organizationId: space.organizationId,@@ -75,7 +75,7 @@ async function getSharedSpacesForVideos(videoIds: string[]) {if (!sharedSpacesMap[org.videoId]) {sharedSpacesMap[org.videoId] = [];}- sharedSpacesMap[org.videoId].push({+ sharedSpacesMap[org.videoId]?.push({id: org.id,name: org.name,organizationId: org.organizationId,diff --git a/apps/web/app/(org)/dashboard/spaces/[spaceId]/components/AddVideosDialogBase.tsx b/apps/web/app/(org)/dashboard/spaces/[spaceId]/components/AddVideosDialogBase.tsxindex 4571b7523..840e6b961 100644--- a/apps/web/app/(org)/dashboard/spaces/[spaceId]/components/AddVideosDialogBase.tsx+++ b/apps/web/app/(org)/dashboard/spaces/[spaceId]/components/AddVideosDialogBase.tsx@@ -83,9 +83,8 @@ const AddVideosDialogBase: React.FC<AddVideosDialogBaseProps> = ({return result.data;},enabled: open,- refetchOnWindowFocus: false, // Don't refetch when window regains focus- staleTime: Infinity, // Consider data fresh forever (until manually invalidated)- gcTime: 1000 * 60 * 5, // Cache for 5 minutes (gcTime is the new name for cacheTime)+ refetchOnWindowFocus: false,+ gcTime: 1000 * 60 * 5,});const { data: entityVideoIds } = useQuery<string[]>({@@ -98,9 +97,8 @@ const AddVideosDialogBase: React.FC<AddVideosDialogBaseProps> = ({return result.data;},enabled: open,- refetchOnWindowFocus: false, // Don't refetch when window regains focus- staleTime: Infinity, // Consider data fresh forever (until manually invalidated)- gcTime: 1000 * 60 * 5, // Cache for 5 minutes (gcTime is the new name for cacheTime)+ refetchOnWindowFocus: false,+ gcTime: 1000 * 60 * 5,});const updateVideosMutation = useMutation({@@ -263,7 +261,7 @@ const AddVideosDialogBase: React.FC<AddVideosDialogBaseProps> = ({{searchTerm? 'Try adjusting your search terms.': videoTab === 'added'- ? `You haven't added any videos to this ${entityName} yet.`+ ? `You haven't added any videos to ${entityName} yet.`: videoTab === 'notAdded'? `Record or upload videos to add them to this ${entityName}.`: `Record or upload videos to see them here.`}diff --git a/packages/ui-solid/src/Button.tsx b/packages/ui-solid/src/Button.tsxindex 9063de969..983bed47b 100644--- a/packages/ui-solid/src/Button.tsx+++ b/packages/ui-solid/src/Button.tsx@@ -10,17 +10,17 @@ const styles = cva(},variants: {variant: {- blue: "bg-blue-9 text-white hover:bg-blue-10 disabled:bg-blue-400 disabled:text-gray-10 outline-blue-300 disabled:outline-blue-400",+ blue: "bg-blue-9 text-white hover:bg-blue-10 disabled:bg-gray-6 disabled:text-gray-9 outline-blue-300 disabled:outline-blue-10",primary:- "bg-gray-12 text-gray-1 hover:bg-gray-11 disabled:text-gray-10 outline-blue-300 disabled:bg-gray-4 disabled:dark:text-gray-9",+ "bg-gray-12 text-gray-1 hover:bg-gray-11 disabled:bg-gray-6 disabled:text-gray-9 outline-blue-300 disabled:bg-gray-4 disabled:dark:text-gray-9",secondary:- "bg-gray-4 enabled:hover:bg-gray-5 text-gray-500 disabled:bg-gray-3 disabled:text-gray-10 outline-blue-300",+ "bg-gray-4 enabled:hover:bg-gray-5 text-gray-500 disabled:bg-gray-6 disabled:text-gray-9 outline-blue-300 disabled:outline-blue-10",destructive:- "bg-red-300 text-gray-50 dark:text-gray-12 dark:disabled:text-gray-10 enabled:hover:bg-red-400 disabled:bg-red-200 outline-red-300",+ "bg-red-300 text-gray-50 dark:text-gray-12 disabled:bg-gray-6 disabled:text-gray-9 enabled:hover:bg-red-400 disabled:bg-red-200 outline-red-300",white:- "bg-gray-1 dark:bg-gray-12 enabled:hover:bg-gray-5 text-gray-500 dark:disabled:bg-gray-300 dark:disabled:text-gray-8 dark:text-gray-1 disabled:bg-gray-400 disabled:text-gray-8 outline-blue-300",+ "bg-gray-1 dark:bg-gray-12 enabled:hover:bg-gray-5 text-gray-500 dark:disabled:bg-gray-300 dark:disabled:text-gray-8 dark:text-gray-1 disabled:bg-gray-6 disabled:text-gray-9 outline-blue-300",lightdark:- "bg-gray-12 hover:bg-gray-11 text-gray-1 dark:disabled:bg-gray-300 dark:disabled:text-gray-8 disabled:bg-gray-400 disabled:text-gray-8",+ "bg-gray-12 hover:bg-gray-11 text-gray-1 dark:disabled:bg-gray-300 dark:disabled:text-gray-8 disabled:bg-gray-6 disabled:text-gray-9",},size: {xs: "text-[0.75rem] px-[0.5rem] h-[1.25rem]",diff --git a/packages/ui/src/components/Button.tsx b/packages/ui/src/components/Button.tsxindex 8f6b8bc0f..d6d39007f 100644--- a/packages/ui/src/components/Button.tsx+++ b/packages/ui/src/components/Button.tsx@@ -13,7 +13,7 @@ const buttonVariants = cva(variants: {variant: {primary: "bg-gray-12 text-gray-1 hover:bg-gray-11 disabled:bg-gray-6 disabled:text-gray-9",- blue: "bg-blue-600 text-white hover:bg-blue-700 disabled:bg-blue-200 disabled:text-gray-8",+ blue: "bg-blue-600 text-white hover:bg-blue-700 disabled:bg-gray-6 disabled:text-gray-9",destructive:"bg-red-500 text-white hover:bg-red-600 disabled:bg-red-200",outline: "border border-gray-8 text-gray-12 hover:bg-gray-2 disabled:bg-gray-8",