adventure: let a player back out from the web, not only in Matrix
Three verbs to match gogobee's: call off an expedition, turn back out of somebody else's party, send the pet sitter home. Which one this page offers is derived here rather than pushed — leadership is already legible in the party seats and the sitter's standing is already in the babysit offer, so nothing new crosses the wire. Two things running it turned up that no test would have. An applied abandon left "Pull out of the run" sitting under a verdict saying the expedition was over, so an applied verb now also hides the other verbs it just made untrue. And a party member was being offered that same button in the first place, beside the one that actually works — Pete knows from the seat it just read that gogobee would refuse it, so it is withheld. Also: heal the Matrix handle onto push rows stored before the column existed, on its own endpoint rather than through the subscribe upsert, which resets both watermarks and would have silenced the digest for anybody who reads the site regularly. And stack the board row below sm — four flex columns that wrapped to six lines on a phone, pre-existing.
This commit is contained in:
@@ -50,6 +50,33 @@
|
||||
});
|
||||
}
|
||||
|
||||
// A subscription stored before the server learned to record the Matrix handle
|
||||
// can never match an owner-scoped adventure alert, and nothing re-subscribes on
|
||||
// its own — subscribe() only runs on a click. So an existing subscription gets
|
||||
// its handle topped up once, silently, from the page it is already on.
|
||||
//
|
||||
// Once per endpoint, not once per load: the marker is the endpoint itself, so a
|
||||
// rotated subscription heals again and a browser that has already done it never
|
||||
// asks twice. The server's update is a no-op on an already-healed row, so a lost
|
||||
// marker costs one wasted request and nothing else.
|
||||
var HEAL_KEY = "pete.pushHeal.v1";
|
||||
|
||||
function healLocalpart(sub) {
|
||||
if (!sub || !sub.endpoint) return;
|
||||
try {
|
||||
if (localStorage.getItem(HEAL_KEY) === sub.endpoint) return;
|
||||
} catch (e) { /* private mode: heal every load rather than never */ }
|
||||
fetch("/api/push/heal", {
|
||||
method: "POST",
|
||||
headers: { "Content-Type": "application/json" },
|
||||
body: JSON.stringify({ endpoint: sub.endpoint }),
|
||||
credentials: "same-origin",
|
||||
}).then(function (res) {
|
||||
if (!res.ok) return;
|
||||
try { localStorage.setItem(HEAL_KEY, sub.endpoint); } catch (e) {}
|
||||
}).catch(function () { /* transient — the next load will do */ });
|
||||
}
|
||||
|
||||
function unsubscribe() {
|
||||
return currentSub().then(function (sub) {
|
||||
if (!sub) return;
|
||||
@@ -153,6 +180,7 @@
|
||||
}
|
||||
currentSub().then(function (sub) {
|
||||
paint(!!sub, sub ? "You'll get a nudge when new stories land." : "Get a nudge when new stories land.");
|
||||
healLocalpart(sub);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user