Skip to content

Commit 4344399

Browse files
authored
fix(cli): skip undefined cues during incremental batch push (#2059)
1 parent 2f6438f commit 4344399

File tree

2 files changed

+22
-11
lines changed

2 files changed

+22
-11
lines changed

.changeset/polite-cats-rhyme.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"lingo.dev": patch
3+
---
4+
5+
Skip undefined cues during VTT incremental batch push

packages/cli/src/cli/loaders/vtt.ts

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -43,18 +43,24 @@ export default function createVttLoader(): ILoader<
4343
}
4444
},
4545
async push(locale, payload, originalInput) {
46-
const output = Object.entries(payload).map(([key, text]) => {
47-
const [id, timeRange, identifier] = key.split("#");
48-
const [startTime, endTime] = timeRange.split("-");
46+
const output = Object.entries(payload).reduce(
47+
(cues: any[], [key, text]) => {
48+
if (!text) return cues;
4949

50-
return {
51-
end: Number(endTime),
52-
identifier: identifier,
53-
start: Number(startTime),
54-
styles: "",
55-
text: text,
56-
};
57-
});
50+
const [, timeRange, identifier] = key.split("#");
51+
const [startTime, endTime] = timeRange.split("-");
52+
53+
cues.push({
54+
end: Number(endTime),
55+
identifier,
56+
start: Number(startTime),
57+
styles: "",
58+
text,
59+
});
60+
return cues;
61+
},
62+
[],
63+
);
5864

5965
const input = {
6066
valid: true,

0 commit comments

Comments
 (0)