fix(sonar): merge identical branches in segment merge (javascript:S1871)
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
4f8a5c6e15
commit
8d61f22ba4
@ -2314,8 +2314,7 @@ STRIKTE FORMAT- UND TEXTREGELN:
|
|||||||
const _abIsNarrSeg = (s) => s?.type !== 'dialogue' || !s.speaker || /^Narrator$/i.test(s.speaker);
|
const _abIsNarrSeg = (s) => s?.type !== 'dialogue' || !s.speaker || /^Narrator$/i.test(s.speaker);
|
||||||
const _abMergedSegment = (a, b) => {
|
const _abMergedSegment = (a, b) => {
|
||||||
let base = a;
|
let base = a;
|
||||||
if (_abIsUnknownSeg(a) && !_abIsUnknownSeg(b)) base = b;
|
if ((_abIsUnknownSeg(a) && !_abIsUnknownSeg(b)) || (_abIsNarrSeg(a) && !_abIsNarrSeg(b))) base = b;
|
||||||
else if (_abIsNarrSeg(a) && !_abIsNarrSeg(b)) base = b;
|
|
||||||
const type = _abIsNarrSeg(base) ? 'narration' : 'dialogue';
|
const type = _abIsNarrSeg(base) ? 'narration' : 'dialogue';
|
||||||
const speaker = type === 'narration' ? 'Narrator' : (base.speaker || 'Unknown');
|
const speaker = type === 'narration' ? 'Narrator' : (base.speaker || 'Unknown');
|
||||||
return {
|
return {
|
||||||
@ -2349,9 +2348,8 @@ STRIKTE FORMAT- UND TEXTREGELN:
|
|||||||
active.arr.splice(leftIdx, 2, merged);
|
active.arr.splice(leftIdx, 2, merged);
|
||||||
if (active.key === 'segments') _audiobook.segments = active.arr;
|
if (active.key === 'segments') _audiobook.segments = active.arr;
|
||||||
else _audiobook.liveSegments = active.arr;
|
else _audiobook.liveSegments = active.arr;
|
||||||
if (!leftRow || !rightRow || leftRow.parentNode !== rightRow.parentNode) {
|
if (!leftRow || !rightRow || leftRow.parentNode !== rightRow.parentNode
|
||||||
_abRedrawSegmentsChunked(active.arr);
|
|| !_abPatchRowRange([leftRow, rightRow], [merged], active.arr)) {
|
||||||
} else if (!_abPatchRowRange([leftRow, rightRow], [merged], active.arr)) {
|
|
||||||
_abRedrawSegmentsChunked(active.arr);
|
_abRedrawSegmentsChunked(active.arr);
|
||||||
}
|
}
|
||||||
_abPersistManualEdit();
|
_abPersistManualEdit();
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user