From 8cda8b6159704d6e43598340321231fef28d718a Mon Sep 17 00:00:00 2001 From: kartikvirendrar Date: Fri, 9 Aug 2024 18:52:50 +0530 Subject: [PATCH] fix timestamp updation issue --- src/common/TimeBoxes.jsx | 10 +++++----- src/config/config.js | 4 ++-- src/containers/Organization/Video/RightPanel.jsx | 4 ++-- .../Organization/Video/TranslationRightPanel.jsx | 4 ++-- .../Organization/Video/VoiceOverRightPanel1.jsx | 4 ++-- src/utils/subtitleUtils.js | 8 +++++--- src/utils/utils.js | 4 ++-- 7 files changed, 20 insertions(+), 18 deletions(-) diff --git a/src/common/TimeBoxes.jsx b/src/common/TimeBoxes.jsx index 8c85513a..aab9beb8 100644 --- a/src/common/TimeBoxes.jsx +++ b/src/common/TimeBoxes.jsx @@ -2,7 +2,7 @@ import React, { memo } from "react"; import { ProjectStyle } from "styles"; import { TextField } from "@mui/material"; -const TimeBoxes = ({ handleTimeChange, time, index, type, readOnly }) => { +const TimeBoxes = ({ handleTimeChange, time, index, type, readOnly, player }) => { const classes = ProjectStyle(); return ( @@ -10,7 +10,7 @@ const TimeBoxes = ({ handleTimeChange, time, index, type, readOnly }) => { - handleTimeChange(event.target.value, index, type, "hours") + handleTimeChange(event.target.value, index, type, "hours", player) } value={time.split(":")[0]} onFocus={(event) => event.target.select()} @@ -36,7 +36,7 @@ const TimeBoxes = ({ handleTimeChange, time, index, type, readOnly }) => { onFocus={(event) => event.target.select()} InputProps={{ inputProps: { min: 0, max: 100 }, readOnly:readOnly }} onChange={(event) => - handleTimeChange(event.target.value, index, type, "minutes") + handleTimeChange(event.target.value, index, type, "minutes", player) } /> @@ -55,7 +55,7 @@ const TimeBoxes = ({ handleTimeChange, time, index, type, readOnly }) => { InputProps={{ inputProps: { min: 0, max: 100 }, readOnly:readOnly }} className={classes.timeInputBox} onChange={(event) => - handleTimeChange(event.target.value, index, type, "seconds") + handleTimeChange(event.target.value, index, type, "seconds", player) } // style={{ @@ -78,7 +78,7 @@ const TimeBoxes = ({ handleTimeChange, time, index, type, readOnly }) => { InputProps={{ inputProps: { min: 0, max: 999 }, readOnly:readOnly }} className={classes.timeInputBox} onChange={(event) => - handleTimeChange(event.target.value, index, type, "miliseconds") + handleTimeChange(event.target.value, index, type, "miliseconds", player) } /> diff --git a/src/config/config.js b/src/config/config.js index 8e5eae50..9f3a0d0e 100644 --- a/src/config/config.js +++ b/src/config/config.js @@ -2,9 +2,9 @@ const configs = { BASE_URL: "https://backend.chitralekha.ai4bharat.org/", BASE_URL_AUTO: process.env.REACT_APP_APIGW_BASE_URL ? process.env.REACT_APP_APIGW_BASE_URL - : "https://backend.dev.chitralekha.ai4bharat.org" + // : "https://backend.dev.chitralekha.ai4bharat.org" // : "https://backend.chitralekha.ai4bharat.org" - // : "http://127.0.0.1:8000", + : "http://127.0.0.1:8000", }; export default configs; diff --git a/src/containers/Organization/Video/RightPanel.jsx b/src/containers/Organization/Video/RightPanel.jsx index 978375e5..8508649d 100644 --- a/src/containers/Organization/Video/RightPanel.jsx +++ b/src/containers/Organization/Video/RightPanel.jsx @@ -463,12 +463,12 @@ const RightPanel = ({ currentIndex, currentSubs,setCurrentIndex, showTimeline, s const handleTimeChange = useCallback( (value, index, type, time) => { - const sub = timeChange(value, index, type, time); + const sub = timeChange(value, index, type, time, player); dispatch(setSubtitles(sub, C.SUBTITLES)); // saveTranscriptHandler(false, true, sub); }, // eslint-disable-next-line - [limit, currentOffset] + [limit, currentOffset, player] ); const onDelete = useCallback( diff --git a/src/containers/Organization/Video/TranslationRightPanel.jsx b/src/containers/Organization/Video/TranslationRightPanel.jsx index 641a029d..152aaaaf 100644 --- a/src/containers/Organization/Video/TranslationRightPanel.jsx +++ b/src/containers/Organization/Video/TranslationRightPanel.jsx @@ -491,11 +491,11 @@ const TranslationRightPanel = ({ currentIndex, currentSubs,setCurrentIndex, show const handleTimeChange = useCallback( (value, index, type, time) => { - const sub = timeChange(value, index, type, time); + const sub = timeChange(value, index, type, time, player); dispatch(setSubtitles(sub, C.SUBTITLES)); }, // eslint-disable-next-line - [limit, currentOffset] + [limit, currentOffset, player] ); const addNewSubtitleBox = useCallback( diff --git a/src/containers/Organization/Video/VoiceOverRightPanel1.jsx b/src/containers/Organization/Video/VoiceOverRightPanel1.jsx index 06f5dd02..fdd99848 100644 --- a/src/containers/Organization/Video/VoiceOverRightPanel1.jsx +++ b/src/containers/Organization/Video/VoiceOverRightPanel1.jsx @@ -554,11 +554,11 @@ const VoiceOverRightPanel1 = ({ currentIndex, setCurrentIndex, showTimeline, seg const handleTimeChange = useCallback( (value, index, type, time) => { - const sub = timeChange(value, index, type, time); + const sub = timeChange(value, index, type, time, player); dispatch(setSubtitles(sub, C.SUBTITLES)); }, // eslint-disable-next-line - [limit, currentOffset] + [limit, currentOffset, player] ); const replaceSelectedText = (text, index) => { diff --git a/src/utils/subtitleUtils.js b/src/utils/subtitleUtils.js index 586267eb..1b259e85 100644 --- a/src/utils/subtitleUtils.js +++ b/src/utils/subtitleUtils.js @@ -60,7 +60,7 @@ export const getKeyCode = (event) => { } }; -export const timeChange = (value, index, type, time) => { +export const timeChange = (value, index, type, time, player) => { const subtitles = store.getState().commonReducer.subtitles; const copySub = [...subtitles]; @@ -70,7 +70,8 @@ export const timeChange = (value, index, type, time) => { time, copySub[index].start_time, index, - type + type, + player, ); } else { copySub[index].end_time = getUpdatedTime( @@ -78,7 +79,8 @@ export const timeChange = (value, index, type, time) => { time, copySub[index].end_time, index, - type + type, + player, ); } diff --git a/src/utils/utils.js b/src/utils/utils.js index 699ce03a..ab2e5e5f 100644 --- a/src/utils/utils.js +++ b/src/utils/utils.js @@ -250,9 +250,9 @@ export const getMilliseconds = (timeInString) => { return 0; }; -export const getUpdatedTime = (value, type, time, index, startEnd) => { +export const getUpdatedTime = (value, type, time, index, startEnd, player) => { const subtitles = store.getState().commonReducer.subtitles; - const videoDuration = store.getState().getVideoDetails.data.video.duration; + const videoDuration = typeof player.getDuration === 'function' ? player.getDuration() : store.getState().getVideoDetails.data.video.duration; let newValue = "";