π¨ The ultimate agentic social media scheduling tool π€
TypeScript nextjsopen-sourceopen-source-social-media-scheduling-toolosspostiz-cloudpostiz-hostedredisscheduling-toolsocial-media-scheduling-tooltypescript
feat(media): pick video thumbnail from the media gallery
Gilad Resisid5c95a701d4f
diff --git a/apps/frontend/src/components/launches/helpers/media.settings.component.tsx b/apps/frontend/src/components/launches/helpers/media.settings.component.tsxindex d64ecbe60..4a9aaa2c1 100644--- a/apps/frontend/src/components/launches/helpers/media.settings.component.tsx+++ b/apps/frontend/src/components/launches/helpers/media.settings.component.tsx@@ -7,6 +7,8 @@ import { useFetch } from '@gitroom/helpers/utils/custom.fetch';import { hasExtension } from '@gitroom/helpers/utils/has.extension';import { useLaunchStore } from '@gitroom/frontend/components/new-launch/store';import { useVariables } from '@gitroom/react/helpers/variable.context';+import { useModals } from '@gitroom/frontend/components/layout/new-modal';+import { MediaBox } from '@gitroom/frontend/components/media/media.component';const postUrlEmitter = new EventEmitter();export const MediaSettingsLayout = () => {@@ -311,6 +313,7 @@ export const MediaComponentInner: FC<{const { onClose, onSelect, media } = props;const setActivateExitButton = useLaunchStore((e) => e.setActivateExitButton);const newFetch = useFetch();+ const modals = useModals();const [newThumbnail, setNewThumbnail] = useState<string | null>(null);const [isEditingThumbnail, setIsEditingThumbnail] = useState(false);const [altText, setAltText] = useState<string>(media?.alt || '');@@ -382,30 +385,55 @@ export const MediaComponentInner: FC<{<div>{!isEditingThumbnail ? (<div className="flex flex-col">- {/* Show existing thumbnail if it exists */}- {(newThumbnail || thumbnail) && (- <div className="flex flex-col space-y-2">- <span className="text-sm text-textColor">- Current Thumbnail:- </span>+ <div className="flex flex-col space-y-2">+ <span className="text-sm text-textColor">Thumbnail:</span>+ {(newThumbnail || thumbnail) && (<imgsrc={newThumbnail || thumbnail}alt="Current thumbnail"className="max-w-full max-h-[500px] object-contain rounded-lg border border-tableBorder"/>- </div>- )}+ )}+ </div>{/* Action Buttons */}- <div className="flex space-x-2">+ <div className="flex space-x-2 mt-[12px]"><buttondisabled={loading}onClick={() => setIsEditingThumbnail(true)}- className="bg-third text-textColor px-6 py-2 rounded-lg hover:bg-opacity-80 transition-all flex-1 border border-tableBorder"+ className="bg-third text-textColor px-6 py-2 rounded-lg hover:bg-opacity-80 transition-all flex-1 border border-tableBorder whitespace-nowrap"+ >+ Select Frame+ </button>+ <button+ disabled={loading}+ onClick={() =>+ modals.openModal({+ title: 'Media Library',+ askClose: false,+ closeOnEscape: true,+ fullScreen: true,+ size: 'calc(100% - 80px)',+ height: 'calc(100% - 80px)',+ children: (close) => (+ <MediaBox+ type="image-static"+ closeModal={close}+ setMedia={(m) => {+ const [first] = m || [];+ if (first) {+ setNewThumbnail(null);+ setThumbnail(first.path);+ setThumbnailTimestamp(null);+ }+ }}+ />+ ),+ })+ }+ className="bg-third text-textColor px-6 py-2 rounded-lg hover:bg-opacity-80 transition-all flex-1 border border-tableBorder whitespace-nowrap">- {media.thumbnail || newThumbnail- ? 'Edit Thumbnail'- : 'Create Thumbnail'}+ From Gallery</button>{(thumbnail || newThumbnail) && (<button@@ -414,9 +442,9 @@ export const MediaComponentInner: FC<{setNewThumbnail(null);setThumbnail(null);}}- className="bg-red-600 text-white px-6 py-2 rounded-lg hover:bg-opacity-80 transition-all flex-1 border border-red-700"+ className="bg-red-600 text-white px-6 py-2 rounded-lg hover:bg-opacity-80 transition-all flex-1 border border-red-700 whitespace-nowrap">- Clear Thumbnail+ Clear</button>)}</div>diff --git a/apps/frontend/src/components/media/media.component.tsx b/apps/frontend/src/components/media/media.component.tsxindex 2dbbd83fc..2052111fb 100644--- a/apps/frontend/src/components/media/media.component.tsx+++ b/apps/frontend/src/components/media/media.component.tsx@@ -203,7 +203,7 @@ const MAX_UPLOAD_SIZE = 1024 * 1024 * 1024; // 1 GBexport const MediaBox: FC<{setMedia: (params: { id: string; path: string }[]) => void;standalone?: boolean;- type?: 'image' | 'video';+ type?: 'image' | 'image-static' | 'video';closeModal: () => void;}> = ({ type, standalone, setMedia }) => {const [page, setPage] = useState(0);@@ -236,6 +236,8 @@ export const MediaBox: FC<{allowedFileTypes:type == 'image'? 'image/*'+ : type == 'image-static'+ ? 'image/jpeg,image/png': type == 'video'? 'video/mp4': 'image/*,video/mp4',@@ -529,6 +531,10 @@ export const MediaBox: FC<{return hasExtension(f.path, 'mp4');} else if (type === 'image') {return !hasExtension(f.path, 'mp4');+ } else if (type === 'image-static') {+ return (+ !hasExtension(f.path, 'mp4') && !hasExtension(f.path, 'gif')+ );}return true;})@@ -776,6 +782,7 @@ export const MultiMediaComponent: FC<{onClick={async () => {modals.openModal({title: t('media_settings', 'Media Settings'),+ size: '720px',children: (close) => (<MediaComponentInnermedia={media as any}