Skip to content

835 extend caption editing area UI#837

Merged
angrave merged 12 commits into
stagingfrom
835-extend-caption-editing-area-ui
Dec 4, 2024
Merged

835 extend caption editing area UI#837
angrave merged 12 commits into
stagingfrom
835-extend-caption-editing-area-ui

Conversation

@dsding2

@dsding2 dsding2 commented Nov 11, 2024

Copy link
Copy Markdown
Contributor

Allows editing of starting and ending timestamps for captions and descriptions.

@dsding2 dsding2 linked an issue Nov 11, 2024 that may be closed by this pull request

@angrave angrave left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changing the DOM is strangel.
(From Chatgpt): Directly manipulating ref.current.innerText might conflict with React's reconciliation process. This could cause React to lose sync with the DOM.

Improvement: If possible, manage text updates via state or props rather than directly mutating the DOM:

const [innerText, setInnerText] = useState(originalValue);

useEffect(() => {
  if (ref.current) ref.current.innerText = innerText;
}, [innerText]);

if (ref.current) {
const elementId = ref.current?.id || "";
const currentValue = ref.current.innerText;
if (elementId.includes("time")) {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This string check seems fragile and prone to break in the future - is the best way to decide what this element is?

} else if (elementId.includes("textarea")) {
// text
// eslint-disable-next-line no-console
console.log("handling blur for text");

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Once this code is ready for the PR the console log should be removed or commented out.

if (!Array.isArray(trans)) {
trans = [trans];
}
console.log("Normalized trans array:", trans);

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment out or remove


// Inplace add a reference to the transcription object for all captions
allTranscriptionData.forEach((captionList, listIndex) =>{
console.log("Fetched allTranscriptionData:", allTranscriptionData);

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment out or remove

*saveCaption({ payload: { caption, text, begin, end } }, { call, put, select }) {
const { watch } = yield select();

console.log("Entering saveCaption with payload:", { caption, text, begin, end });

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment out or remove

} catch (error) {
// eslint-disable-next-line no-console
console.error("Error during save:", error.message);
alert('Please enter a valid time format (HH:MM:SS, MM:SS, or HH:MM:SS.SSS)'); // eslint-disable-line no-alert

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use a better alert library (ClassTranscribe already has a couple included) than the js builtin 'alert'

@angrave

angrave commented Dec 4, 2024

Copy link
Copy Markdown
Collaborator

Is this is ready for merging in staging?e.g. Has it been sufficiently tested? Can you show me a demo? (Does it need other merges or backend changes first?)

@angrave angrave merged commit d5d09ee into staging Dec 4, 2024
@angrave angrave deleted the 835-extend-caption-editing-area-ui branch December 4, 2024 22:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Extend caption editing area UI

3 participants