Skip to content

Commit

Permalink
Merge branch 'develop' into ai-transcribes
Browse files Browse the repository at this point in the history
  • Loading branch information
Mario-SO authored Jan 9, 2025
2 parents 921b78a + c7af994 commit 13291be
Show file tree
Hide file tree
Showing 25 changed files with 851 additions and 215 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,21 +34,25 @@ export default function Clip({ session }: { session: IExtendedSession }) {
// getAsset();
// }, 10000);
// return () => clearInterval(interval);
// } else if (session.processingStatus === ProcessingStatus.pending) {
// } else if (
// session.processingStatus === ProcessingStatus.pending ||
// session.processingStatus === ProcessingStatus.rendering
// ) {
// const interval = setInterval(() => {
// router.refresh();
// }, 10000);
// return () => clearInterval(interval);
// }
// // eslint-disable-next-line react-hooks/exhaustive-deps
// }, [asset?.status?.phase]);
// }, [asset?.status?.phase, session.processingStatus]);
// if (!assetId) return null;

return (
<>
<div>
{asset?.status?.phase === 'processing' ||
session.processingStatus === ProcessingStatus.pending ? (
session.processingStatus === ProcessingStatus.pending ||
session.processingStatus === ProcessingStatus.rendering ? (
<Card className="w-full cursor-not-allowed animate-pulse max-w-2xl overflow-hidden px-2 py-1 shadow-none bg-muted">
<div className="flex justify-center items-center">
<div className="flex-shrink-0 w-1/3">
Expand All @@ -57,7 +61,9 @@ export default function Clip({ session }: { session: IExtendedSession }) {
<CardContent className="lg:p-2 p-2 flex-grow">
<h2 className="text-lg font-semibold line-clamp-1">{name}</h2>
<p className="text-sm text-gray-500 mt-1">
Video is processing...
{session.processingStatus === ProcessingStatus.rendering
? 'Video is rendering...'
: 'Video is processing...'}
</p>
<div className="flex items-center justify-between gap-2">
{asset?.status?.phase === 'processing' && (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,13 @@ const CreateClipButton = ({
const session = await fetchSession({ session: sessionId });
if (!session) {
toast.error('Failed to fetch session');
console.error('🚨 Session fetch failed');
return;
}
setSessionRecording(session);
console.log('🔄 Session fetched successfully');
} catch (error) {
console.error('Error fetching session:', error);
console.error('🚨 Error fetching session:', error);
toast.error('Failed to fetch session data');
}
};
Expand All @@ -66,11 +68,13 @@ const CreateClipButton = ({
const stageData = await fetchStage({ stage: stageId });
if (!stageData) {
toast.error('Failed to fetch stage');
console.error('🚨 Stage fetch failed');
return;
}
setStage(stageData);
console.log('🔄 Stage fetched successfully');
} catch (error) {
console.error('Error fetching stage:', error);
console.error('🚨 Error fetching stage:', error);
toast.error('Failed to fetch stage data');
}
};
Expand All @@ -85,6 +89,7 @@ const CreateClipButton = ({
if (videoRef.current) {
videoRef.current.currentTime = startTime.displayTime;
videoRef.current.play();
console.log('🔄 Preview started');
}
};

Expand Down Expand Up @@ -133,6 +138,7 @@ const CreateClipButton = ({
stageId: stageId,
speakers: [],
});
console.log('🔄 Marker cleared');
};

useEffect(() => {
Expand All @@ -154,6 +160,7 @@ const CreateClipButton = ({
})) ?? [],
pretalxSessionCode: selectedMarker.pretalxSessionCode,
});
console.log('🔄 Marker data reset');
}
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [selectedMarker]);
Expand All @@ -165,11 +172,13 @@ const CreateClipButton = ({
(!sessionRecording?.assetId && !liveRecordingId)
) {
setIsCreateClip(false);
console.error('🚨 Missing required data for clip creation');
return toast.error('Missing required data for clip creation');
}

if (endTime.unix < startTime.unix) {
setIsCreateClip(false);
console.error('🚨 End time must be greater than start time');
return toast.error('End time must be greater than start time');
}

Expand Down Expand Up @@ -208,24 +217,26 @@ const CreateClipButton = ({
};

if (hasEditorOptions) {
const events = [
...(values.outroAnimation ? [{
videoUrl: values.outroAnimation,
label: 'outro',
}] : []),
...(values.introAnimation ? [{
videoUrl: values.introAnimation,
label: 'intro',
}] : []),
{
sessionId: session._id as string,
label: 'main',
},
];

const clipCreationOptions = {
...mainClipData,
isEditorEnabled: true,
editorOptions: {
events: [
{
sessionId: values.outroAnimation as string,
label: 'outro',
},
{
sessionId: values.introAnimation as string,
label: 'intro',
},
{
sessionId: session._id as string,
label: 'main',
},
],
events,
captionEnabled: values.captionEnabled,
selectedAspectRatio: values.selectedAspectRatio as string,
frameRate: 30,
Expand All @@ -235,16 +246,20 @@ const CreateClipButton = ({
captionFont: 'Arial',
},
};
console.log('Creating clip with options:', JSON.stringify(clipCreationOptions, null, 2));
// Call createClipAction with the prepared editor options
await createClipAction(clipCreationOptions);
console.log('🔄 Clip created with editor options');
} else {
console.log('Creating clip without editor options:', JSON.stringify(mainClipData, null, 2));
await createClipAction({ ...mainClipData, isEditorEnabled: false });
console.log('🔄 Clip created without editor options');
}

toast.success('Clip created');
setIsCreatingClip(false);
} catch (error) {
console.error('Error creating clip:', error);
console.error('🚨 Error creating clip:', error);
toast.error(
error instanceof Error ? error.message : 'Error creating clip'
);
Expand All @@ -268,4 +283,4 @@ const CreateClipButton = ({
);
};

export default CreateClipButton;
export default CreateClipButton;
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
import React, { useState } from 'react';
import { IExtendedSession } from '@/lib/types';
import { SessionType } from 'streameth-new-server/src/interfaces/session.interface';
import Dropzone from '@/app/studio/[organization]/(root)/library/components/upload/Dropzone';
import { Uploads } from '@/app/studio/[organization]/(root)/library/components/UploadVideoDialog';
import {
Form,
FormControl,
Expand All @@ -19,6 +17,8 @@ import { z } from 'zod';
import { clipSchema } from '@/lib/schema';
import { Button } from '@/components/ui/button';
import Combobox from '@/components/ui/combo-box';
import VideoUpload from '@/components/misc/form/videoUpload';
import { Uploads } from '@/app/studio/[organization]/(root)/library/components/UploadVideoDialog';

const SelectAnimation = ({
animations,
Expand Down Expand Up @@ -59,15 +59,14 @@ const SelectAnimation = ({
items={[
...animations.map((animation) => ({
label: animation.name,
value: animation._id,
})),
value: animation.videoUrl || '',
})).filter(item => item.value),
]}
variant="outline"
value={field.value as string}
value={field.value || ''}
setValue={(value) => {
if (value) {
field.onChange(value);
// Clear uploads when an animation is selected
setUpload({});
}
}}
Expand All @@ -78,7 +77,7 @@ const SelectAnimation = ({
{field.value ? ( // Check if an animation is selected
<div className="flex flex-col items-center justify-center gap-1 border-2 p-2 h-40 border-dashed rounded-md">
<span>
{animations.find((a) => a._id === field.value)?.name}
Selected video
</span>
<Button
variant={'destructive'}
Expand All @@ -93,15 +92,16 @@ const SelectAnimation = ({
</Button>
</div>
) : (
<Dropzone
uploads={upload}
setUploads={setUpload}
organizationId={organizationId}
stageId={stageId}
onChange={field.onChange}
type={SessionType.animation}
maxFiles={1}
maxSize={50 * 1024 * 1024}
<VideoUpload
path={`organizations/${organizationId}/animations`}
options={{
placeholder: 'Upload animation video (max 15MB)',
maxSize: 15 * 1024 * 1024, // 15MB
}}
onChange={(e) => {
// Store the S3 URL directly
field.onChange(e.target.value);
}}
/>
)}
</div>
Expand Down
47 changes: 37 additions & 10 deletions packages/app/components/misc/UserProfile.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import Image from 'next/image';
import { IExtendedOrganization } from '@/lib/types';
import { fetchOrganization } from '@/lib/services/organizationService';
import Link from 'next/link';
import { LayoutDashboard, Home, Users, LogOut } from 'lucide-react';

const UserProfile = async ({
organization,
Expand Down Expand Up @@ -42,23 +43,49 @@ const UserProfile = async ({
</DropdownMenuTrigger>
<DropdownMenuContent className="w-56">
<DropdownMenuItem>
<Link href={`/${organization}`}>
<Button className="hidden lg:block" variant={'link'}>
View channel page
<Link
href={`/studio/${organization}`}
className="flex items-center w-full"
>
<Button
className="hidden lg:flex items-center space-x-2"
variant={'link'}
>
<LayoutDashboard size={16} />
<span>View studio</span>
</Button>
</Link>
</DropdownMenuItem>
<DropdownMenuItem>
<Link href={`/studio`}>
<Button className="hidden lg:block" variant={'link'}>
Switch Accounts
<Link href={`/${organization}`} className="flex items-center w-full">
<Button
className="hidden lg:flex items-center space-x-2"
variant={'link'}
>
<Home size={16} />
<span>View channel page</span>
</Button>
</Link>
</DropdownMenuItem>
<DropdownMenuItem>
<Link href="/auth/logout" className="w-full">
<Button className="hidden lg:block" variant={'link'}>
Logout
<Link href={`/studio`} className="flex items-center w-full">
<Button
className="hidden lg:flex items-center space-x-2"
variant={'link'}
>
<Users size={16} />
<span>Switch Accounts</span>
</Button>
</Link>
</DropdownMenuItem>
<DropdownMenuItem>
<Link href="/auth/logout" className="flex items-center w-full">
<Button
className="hidden lg:flex items-center space-x-2"
variant={'link'}
>
<LogOut size={16} />
<span>Logout</span>
</Button>
</Link>
</DropdownMenuItem>
Expand All @@ -67,4 +94,4 @@ const UserProfile = async ({
);
};

export default UserProfile;
export default UserProfile;
Loading

0 comments on commit 13291be

Please sign in to comment.