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:
knight 2025-11-05 01:09:21 -05:00
parent 1a4a1bd095
commit e241d206c5

View File

@ -359,13 +359,23 @@
segmentDiv.dataset.text = (segment.text || '').toLowerCase(); segmentDiv.dataset.text = (segment.text || '').toLowerCase();
// Handle multiple possible timestamp field names and formats // Handle multiple possible timestamp field names and formats
let startSeconds = segment.start_seconds // Try each field and ensure it's a valid number
|| segment.start let startSeconds = 0;
|| segment.offset const possibleFields = [
|| segment.time segment.start_seconds,
|| segment.timestamp segment.start,
|| segment.startTime segment.offset,
|| 0; 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 timestamp is in milliseconds (> 10000 for timestamps after ~2.7 hours), convert to seconds
if (startSeconds > 10000) { if (startSeconds > 10000) {