adelevett commited on
Commit
05fd0be
·
1 Parent(s): d53ff97

frontend update

Browse files
Files changed (1) hide show
  1. theater_template.html +11 -36
theater_template.html CHANGED
@@ -367,43 +367,18 @@
367
  return colors[index];
368
  }
369
 
370
- // Prep and flatten messages with random offsets within segment durations
 
371
  function prepareMessages() {
372
- flattenedMessages = [];
373
-
374
- for (let i = 0; i < chatData.length; i++) {
375
- const segment = chatData[i];
376
- const start = segment.timestamp;
377
-
378
- // Find next segment timestamp to determine segment duration
379
- const nextStart = (i < chatData.length - 1) ? chatData[i+1].timestamp : start + 30;
380
- const duration = Math.max(5, nextStart - start);
381
-
382
- const messages = segment.messages || [];
383
- messages.forEach((msg, index) => {
384
- // Spread messages evenly or randomly across the duration
385
- const randomOffset = Math.random() * duration;
386
- const displayTime = start + randomOffset;
387
-
388
- // Generate unique ID
389
- const id = `${start}_${index}_${msg.username}`;
390
-
391
- // Assign visual badges
392
- const isMod = (index % 15 === 0);
393
- const isSub = (index % 4 === 0) && !isMod;
394
-
395
- flattenedMessages.push({
396
- id: id,
397
- displayTime: displayTime,
398
- username: msg.username,
399
- text: msg.text,
400
- isMod: isMod,
401
- isSub: isSub
402
- });
403
- });
404
- }
405
-
406
- // Sort messages by displayTime
407
  flattenedMessages.sort((a, b) => a.displayTime - b.displayTime);
408
  }
409
 
 
367
  return colors[index];
368
  }
369
 
370
+ // chatData is a flat list of messages with precomputed numeric displayTime.
371
+ // No segment loops, no timestamp arithmetic, no NaN path.
372
  function prepareMessages() {
373
+ flattenedMessages = chatData.map((msg, index) => ({
374
+ id: msg.id || `msg_${index}`,
375
+ displayTime: msg.displayTime, // numeric, pre-computed by pipeline
376
+ username: msg.username,
377
+ text: msg.text,
378
+ isMod: (index % 15 === 0),
379
+ isSub: (index % 4 === 0) && !(index % 15 === 0),
380
+ }));
381
+ // Guaranteed numeric sort displayTime is never a string or NaN.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
382
  flattenedMessages.sort((a, b) => a.displayTime - b.displayTime);
383
  }
384