Fix NaN timestamps with proper type checking
Previous || chain could pass through invalid values causing NaN. Now explicitly checks each possible timestamp field with: - null check (field != null) - NaN check (!isNaN(parseFloat(field))) - Takes first valid numeric value found This ensures timestamps always have a valid number, defaulting to 0 if no valid timestamp field is found. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
parent
1a4a1bd095
commit
e241d206c5
@ -359,13 +359,23 @@
|
||||
segmentDiv.dataset.text = (segment.text || '').toLowerCase();
|
||||
|
||||
// Handle multiple possible timestamp field names and formats
|
||||
let startSeconds = segment.start_seconds
|
||||
|| segment.start
|
||||
|| segment.offset
|
||||
|| segment.time
|
||||
|| segment.timestamp
|
||||
|| segment.startTime
|
||||
|| 0;
|
||||
// Try each field and ensure it's a valid number
|
||||
let startSeconds = 0;
|
||||
const possibleFields = [
|
||||
segment.start_seconds,
|
||||
segment.start,
|
||||
segment.offset,
|
||||
segment.time,
|
||||
segment.timestamp,
|
||||
segment.startTime
|
||||
];
|
||||
|
||||
for (const field of possibleFields) {
|
||||
if (field != null && !isNaN(parseFloat(field))) {
|
||||
startSeconds = parseFloat(field);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// If timestamp is in milliseconds (> 10000 for timestamps after ~2.7 hours), convert to seconds
|
||||
if (startSeconds > 10000) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user