Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions components/SummaryMeetingInfo.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { useState, useEffect } from 'react';
import { useState, useEffect, useCallback } from 'react';
import styles from '../styles/typea.module.css';
import { useMyVariable } from '../context/MyVariableContext';
import SelectNames from './SelectNames';
Expand Down Expand Up @@ -154,7 +154,7 @@ const SummaryMeetingInfo: React.FC<SummaryMeetingInfoProps> = ({ workgroup, onUp
});
}, [myVariable.summary?.meetingInfo]); // Add myVariable.summary.meetingInfo to the dependency array

const handleVideoDataUpdate = (newVideoData: any) => {
const handleVideoDataUpdate = useCallback((newVideoData: any) => {
setMeetingInfo(prevMeetingInfo => {
if (JSON.stringify(prevMeetingInfo.timestampedVideo) === JSON.stringify(newVideoData)) {
return prevMeetingInfo;
Expand All @@ -164,7 +164,7 @@ const SummaryMeetingInfo: React.FC<SummaryMeetingInfoProps> = ({ workgroup, onUp
timestampedVideo: newVideoData,
};
});
};
}, []);

return (
<>
Expand Down
2 changes: 1 addition & 1 deletion components/SummaryTemplate.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ const SummaryTemplate = ({ updateMeetings }: SummaryTemplateProps) => {
transcriptLink: "",
mediaLink: "",
workingDocs: [{ title: "", link: "" }],
timestampedVideo: { url: "", intro: "", timestamps: [{ title: "", timestamp: "" }] }
timestampedVideo: { url: "", intro: "", timestamps: "" }
},
agendaItems: [
{
Expand Down
21 changes: 16 additions & 5 deletions components/TimestampedVideo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,26 @@ const TimestampedVideo: React.FC<TimestampedVideoProps> = ({ onUpdate, initialDa
timestamps: initialData?.timestamps || '',
});

useEffect(() => {
// Update videoData when initialData changes
setVideoData({
url: initialData?.url || '',
intro: initialData?.intro || '',
timestamps: initialData?.timestamps || '',
});
}, [initialData]);

const handleChange = (e: React.ChangeEvent<HTMLInputElement | HTMLTextAreaElement>) => {
const { name, value } = e.target;
setVideoData({ ...videoData, [name]: value });
setVideoData((prevVideoData: any) => {
const updatedVideoData = { ...prevVideoData, [name]: value };
if (prevVideoData[name] !== value) {
setTimeout(() => onUpdate(updatedVideoData), 0); // Delay the onUpdate call
}
return updatedVideoData;
});
};

useEffect(() => {
onUpdate(videoData); // Call onUpdate with the current state of videoData
}, [videoData, onUpdate]); // Add videoData and onUpdate to the dependency array

return (
<div className={styles.container}>
<div className={styles.field}>
Expand Down