From e241d206c5dd29fcef59b110a1b16b4c6b64a18f Mon Sep 17 00:00:00 2001 From: knight Date: Wed, 5 Nov 2025 01:09:21 -0500 Subject: [PATCH] Fix NaN timestamps with proper type checking MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- static/app.js | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/static/app.js b/static/app.js index d57b14d..e362b98 100644 --- a/static/app.js +++ b/static/app.js @@ -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) {