Skip to content

Commit

Permalink
feat: connect questions to video
Browse files Browse the repository at this point in the history
  • Loading branch information
ezhil56x committed Oct 5, 2024
1 parent 97623f4 commit 1d561d8
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions src/components/NewPostDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,6 @@ export const NewPostDialog = () => {
let timeoutId: any;
if (paramsObject.newPost === 'open') {
onOpen();

const videoIdFromUrl = paramsObject.videoId as string;
const videoTitleFromUrl = paramsObject.videoTitle as string;

if (videoIdFromUrl && videoTitleFromUrl) {
setVideoId(videoIdFromUrl);
setVideoTitle(videoTitleFromUrl);
}
} else {
onClose();
}
Expand All @@ -59,6 +51,13 @@ export const NewPostDialog = () => {
};
}, [onClose, onOpen, paramsObject.newPost]);

useEffect(() => {
if (paramsObject.newPost === 'open') {
setVideoId(paramsObject.videoId as string);
setVideoTitle(paramsObject.videoTitle as string);
}
}, [paramsObject.newPost, paramsObject.videoId, paramsObject.videoTitle]);

const { execute, fieldErrors, setFieldErrors } = useAction(createQuestion, {
onSuccess: (data) => {
toast.success(`Question "${data.title}" created`);
Expand Down

0 comments on commit 1d561d8

Please sign in to comment.