Skip to content

Commit

Permalink
Merge pull request #785 from AI4Bharat/timebox-fix
Browse files Browse the repository at this point in the history
fix timestamp updation issue
  • Loading branch information
aparna-aa authored Aug 9, 2024
2 parents bc5537c + 8cda8b6 commit 35d0019
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 18 deletions.
10 changes: 5 additions & 5 deletions src/common/TimeBoxes.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@ 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 (
<div style={{display: "flex", margin:"0"}}>
<TextField
variant="standard"
onChange={(event) =>
handleTimeChange(event.target.value, index, type, "hours")
handleTimeChange(event.target.value, index, type, "hours", player)
}
value={time.split(":")[0]}
onFocus={(event) => event.target.select()}
Expand All @@ -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)
}
/>

Expand All @@ -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={{

Expand All @@ -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)
}
/>
</div>
Expand Down
4 changes: 2 additions & 2 deletions src/config/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
4 changes: 2 additions & 2 deletions src/containers/Organization/Video/RightPanel.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
4 changes: 2 additions & 2 deletions src/containers/Organization/Video/TranslationRightPanel.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
4 changes: 2 additions & 2 deletions src/containers/Organization/Video/VoiceOverRightPanel1.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand Down
8 changes: 5 additions & 3 deletions src/utils/subtitleUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -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];

Expand All @@ -70,15 +70,17 @@ export const timeChange = (value, index, type, time) => {
time,
copySub[index].start_time,
index,
type
type,
player,
);
} else {
copySub[index].end_time = getUpdatedTime(
value,
time,
copySub[index].end_time,
index,
type
type,
player,
);
}

Expand Down
4 changes: 2 additions & 2 deletions src/utils/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = "";

Expand Down

0 comments on commit 35d0019

Please sign in to comment.