@ywkrlerche/richardwho 1.0.47 → 1.0.49

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/app.js CHANGED
@@ -1093,6 +1093,8 @@
1093
1093
  // Newest first. Add an entry here with every publish; its version should match package.json.
1094
1094
  // Each has: new (features), games (added/removed/fixed games), fixes (bugs). Leave a list out if empty.
1095
1095
  const CHANGELOG = [
1096
+ { version: "1.0.48", date: "2026-11-16",
1097
+ new: [], fixes: ["The \"in chat right now\" count no longer gets stuck: people who close the chat or lose connection drop off within a couple of minutes"] },
1096
1098
  { version: "1.0.47", date: "2026-11-16",
1097
1099
  new: ["🌴 New theme: Vice, a pastel waterfront inspired by GTA 6, with boats, birds, clouds and a busy causeway. It's on for everyone during GTA 6 launch week", "⏳ A GTA 6 countdown on the home page, with fireworks on launch day (November 19)", "🔥 The Games page now lists the most played games first (switch to A–Z in the sort menu)", "🎮 29 new games, including Freddy Fazbear's Pizzeria Simulator, Evolve, Trimps, Synergism, Shark Game, A Dark Room, Going Balls and RigBMX"], fixes: ["Fixed big games getting stuck on loading forever (Angry Birds, Retro Bowl College, Vex X3M and more): when the main download server stalls, the site now switches to a backup within seconds", "Fixed games that got stuck partway through loading their own files (Build a Queen and other 3D games)", "Gladi Hoppers and Choppy Orc have their real pictures", "2048 Merge Run was removed: its game files were deleted by their owner"] },
1098
1100
  { version: "1.0.45", date: "2026-11-13",
@@ -1874,6 +1876,7 @@
1874
1876
  stopTyping();
1875
1877
  typing.ref = null;
1876
1878
  if (hereOn && hereRef) hereRef.remove().catch(() => {});
1879
+ clearInterval(hereBeat);
1877
1880
  hereOn = false;
1878
1881
  hereRef = null;
1879
1882
  chat.room = room;
@@ -3953,8 +3956,16 @@
3953
3956
  else if (mention) b.classList.add("has-mention");
3954
3957
  });
3955
3958
  }
3956
- // "N in chat right now": chat/here/<id> exists while this browser has the chat open (or the live stream)
3957
- let hereRef = null, hereOn = false;
3959
+ // "N in chat right now": chat/here/<id> = when this browser last checked in. It checks in every minute while
3960
+ // the chat is open, and again whenever the connection comes back (a sleeping Chromebook drops it). Only check-ins
3961
+ // from the last 2½ minutes count, and anyone's page sweeps away entries over 5 minutes old, so nobody gets stuck.
3962
+ const HERE_FRESH = 150e3, HERE_STALE = 300e3;
3963
+ let hereRef = null, hereOn = false, hereBeat = 0, hereConnWatched = false, hereSnap = null;
3964
+ function checkIn() {
3965
+ if (!hereOn || !hereRef) return;
3966
+ hereRef.onDisconnect().remove();
3967
+ hereRef.set(window.firebase.database.ServerValue.TIMESTAMP).catch(() => {});
3968
+ }
3958
3969
  async function updateHere() {
3959
3970
  const want = chatShowing();
3960
3971
  if (want === hereOn || !chat.uid) return;
@@ -3962,17 +3973,32 @@
3962
3973
  if (!app) return;
3963
3974
  hereOn = want;
3964
3975
  hereRef ||= app.database().ref(roomPath(`here/${chat.uid}`));
3965
- if (want) { hereRef.onDisconnect().remove(); hereRef.set(true).catch(() => {}); }
3966
- else hereRef.remove().catch(() => {});
3976
+ clearInterval(hereBeat);
3977
+ if (want) {
3978
+ checkIn();
3979
+ hereBeat = setInterval(checkIn, 60e3);
3980
+ if (!hereConnWatched) { hereConnWatched = true; app.database().ref(".info/connected").on("value", (s) => { if (s.val()) checkIn(); }); }
3981
+ } else hereRef.remove().catch(() => {});
3982
+ }
3983
+ function drawHere() {
3984
+ if (!hereSnap) return;
3985
+ const now = serverNow(), where = chat.room === "live" ? "watching" : "in chat";
3986
+ let n = 0;
3987
+ hereSnap.forEach((c) => {
3988
+ const v = c.val();
3989
+ if (typeof v === "number" && now - v < HERE_FRESH) n++;
3990
+ else if (v === true || (typeof v === "number" && now - v > HERE_STALE)) c.ref.remove().catch(() => {}); // stuck from a missed disconnect
3991
+ });
3992
+ if (hereOn && !hereSnap.hasChild(chat.uid)) n++; // this browser, before its check-in arrives
3993
+ $("chat-here-n").textContent = n <= 1 ? `Just you ${where}` : `${n} ${where} right now`;
3967
3994
  }
3968
3995
  function watchHere(db) {
3969
3996
  chat.hereWatch?.off();
3997
+ hereSnap = null;
3970
3998
  chat.hereWatch = db.ref(roomPath("here"));
3971
- const where = chat.room === "live" ? "watching" : "in chat";
3972
- chat.hereWatch.on("value", (s) => {
3973
- const n = s.numChildren();
3974
- $("chat-here-n").textContent = n <= 1 ? `Just you ${where}` : `${n} ${where} right now`;
3975
- }, () => { $("chat-here-n").textContent = ""; });
3999
+ chat.hereWatch.on("value", (s) => { hereSnap = s; drawHere(); }, () => { $("chat-here-n").textContent = ""; });
4000
+ clearInterval(chat.hereTimer);
4001
+ chat.hereTimer = setInterval(drawHere, 30e3); // people drop off as their check-ins get old, without any new data
3976
4002
  }
3977
4003
  // Full-screen chat: the chat box covers the whole page (Esc or the button leaves)
3978
4004
  function setChatFull(on) {