File tree Expand file tree Collapse file tree 1 file changed +34
-1
lines changed
Expand file tree Collapse file tree 1 file changed +34
-1
lines changed Original file line number Diff line number Diff line change 22
33import { db } from "@cap/database" ;
44import { getCurrentUser } from "@cap/database/auth/session" ;
5+ import { nanoId } from "@cap/database/helpers" ;
56import {
67 folders ,
78 sharedVideos ,
@@ -50,7 +51,39 @@ export async function addVideosToFolder(
5051
5152 const isAllSpacesEntry = spaceId === user . activeOrganizationId ;
5253
53- //if video already exists in the space, then move it
54+ //if we're adding videos to a folder from Caps page, then insert the videos into the folder
55+ if ( isAllSpacesEntry && folder . spaceId ) {
56+ await db ( )
57+ . insert ( sharedVideos )
58+ . values (
59+ validVideoIds . map ( ( videoId ) => {
60+ const id = nanoId ( ) ;
61+ return {
62+ id,
63+ videoId,
64+ folderId,
65+ organizationId : user . activeOrganizationId ,
66+ sharedByUserId : user . id ,
67+ } ;
68+ } ) ,
69+ ) ;
70+ } else {
71+ await db ( )
72+ . insert ( spaceVideos )
73+ . values (
74+ validVideoIds . map ( ( videoId ) => {
75+ const id = nanoId ( ) ;
76+ return {
77+ id,
78+ videoId,
79+ folderId,
80+ spaceId,
81+ addedById : user . id ,
82+ } ;
83+ } ) ,
84+ ) ;
85+ }
86+
5487 if ( isAllSpacesEntry ) {
5588 await db ( )
5689 . update ( sharedVideos )
You can’t perform that action at this time.
0 commit comments