From fadcfaa7bf11ba6db7707512061bf0c4cad12ba6 Mon Sep 17 00:00:00 2001 From: martbost Date: Tue, 17 Nov 2026 07:31:34 -0600 Subject: [PATCH] netdeals.js: the first ask after a boot waits for the hub once (shared copy, Network Weekend 2026-11-17) Co-Authored-By: Claude Opus 5.5 --- netdeals.js | 3 ++- public/assets/netweekend.js | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/netdeals.js b/netdeals.js index e708583..f24c466 100644 --- a/netdeals.js +++ b/netdeals.js @@ -45,7 +45,8 @@ function withLocal(body, self) { }).filter(Boolean) })) }; } // GET /api/network-deals: public, short cache, the same answer on every page. self = this site's network id (NETWORK_SITE_ID). -function handle(req, res, self) { +async function handle(req, res, self) { + if (!cache.at) { try { await refresh(); } catch (e) {} } // first ask after a boot waits for the hub once (2.5 s cap) const me = String(self || process.env.NETWORK_SITE_ID || '').trim().toLowerCase(); const body = Object.assign({ self: me }, withLocal(current(), me)); res.writeHead(200, { 'Content-Type': 'application/json; charset=utf-8', 'Cache-Control': 'public, max-age=60', 'X-Content-Type-Options': 'nosniff' }); diff --git a/public/assets/netweekend.js b/public/assets/netweekend.js index 7bbb5d3..f92b2df 100644 --- a/public/assets/netweekend.js +++ b/public/assets/netweekend.js @@ -26,7 +26,7 @@ var mine = (ev.deals || []).filter(function (d) { return d.site === me && t < Date.parse(d.endsAt || ev.endsAt); })[0]; var line = mine ? ((mine.byDay && mine.byDay[day]) || mine.text) : ''; var label = (ev.days && ev.days[day]) || ''; - var onDealsPage = ev.url && (location.origin + location.pathname) === ev.url; + var onDealsPage = !!ev.url && (function () { try { var u = new URL(ev.url); return location.pathname === u.pathname && (location.hostname === u.hostname || me === 'iap'); } catch (e) { return false; } })(); remove(); bar = document.createElement('div'); bar.className = 'nw-ribbon'; bar.setAttribute('role', 'region'); bar.setAttribute('aria-label', ev.name);