From 495bebab26d353a9b159ebee596faee8bc3f198e Mon Sep 17 00:00:00 2001 From: techming Date: Wed, 13 Sep 2023 21:23:46 -0500 Subject: [PATCH] fix: missing content for the last paragraph --- frontend/src/pages/Home.js | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/frontend/src/pages/Home.js b/frontend/src/pages/Home.js index 7a9d3dc..48ad826 100644 --- a/frontend/src/pages/Home.js +++ b/frontend/src/pages/Home.js @@ -117,11 +117,18 @@ const Home = () => { } const result = []; let buffer = ""; - transcription.paragraphs.forEach((para) => { - if (curSpeaker !== para.speaker) { + transcription.paragraphs.forEach((para, idx) => { + if ( + curSpeaker !== para.speaker || + idx === transcription.paragraphs.length - 1 + ) { + // The first speaker change (-1 to first real speaker number) + // has no content if (curSpeaker !== -1) { - // change of speaker - let speakerContent = ""; + // We have pushed paragraphs into the buffer of + // the current speaker and now we are about to + // change the speaker + let speakerContent = ""; // determine the format of speaker title and name if ( !speakers[curSpeaker].firstname && !speakers[curSpeaker].lastname @@ -141,6 +148,7 @@ const Home = () => { speakerContent += speakers[curSpeaker].lastname; } } + // Push formatted content as a new paragraph const paraElement = (

{speakerContent}