Keep the expedition view in sync with other players and only send alerts players still want
- The expeditions page rereads its view on its own: every 10 seconds while a group is shown, every 20 seconds otherwise, on tab return and at the next recruitment deadline; late responses no longer overwrite a newer action. A failed load offers "Réessayer" and a failed refresh keeps the last view. - The periodic alert pass first departs groups whose recruitment ended, so their return is announced even if nobody visits the site. - Queued alerts are checked again at sending time: a player who opted out or alerts switched off by the administration drop the message for good. - The engraving confirmation sticks to the bottom of its window, the workshop lists commons by spare count, the guild expeditions card shows the Great Void, and stale help texts and comments are fixed. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
30413de036
commit
84b0d69b1f
13 changed files with 174 additions and 24 deletions
|
|
@ -47,9 +47,11 @@ export const alertMethods = {
|
|||
}
|
||||
},
|
||||
|
||||
// Expéditions rentrées depuis le dernier passage : une alerte par joueur qui l'a activée, une seule fois par expédition.
|
||||
// Expéditions rentrées depuis le dernier passage : une alerte par joueur qui l'a activée, une seule fois par expédition. Les groupes
|
||||
// dont l'inscription est échue partent d'abord : sans visite de joueur, leur retour serait sinon invisible au passage périodique.
|
||||
queueReturnAlerts() {
|
||||
if (!this.alertsActive()) return 0;
|
||||
this.settleForming();
|
||||
let queued = 0;
|
||||
this.cards.database.transaction(() => {
|
||||
const rows = this.db.prepare(`SELECT e.id, e.setup_json, m.player_id, p.discord_id, a.expedition_returned FROM expedition_members m
|
||||
|
|
@ -67,10 +69,24 @@ export const alertMethods = {
|
|||
return queued;
|
||||
},
|
||||
|
||||
// Messages à envoyer. Au moment de l'envoi, l'alerte doit encore être voulue : coupée par l'administration, ou désactivée par le
|
||||
// joueur pour ce type de message, elle est abandonnée (marquée en échec, jamais renvoyée plus tard, quand elle serait périmée).
|
||||
pendingAlerts(limit = 20) {
|
||||
return this.db.prepare(`SELECT o.id, o.content, o.attempts, p.discord_id FROM alert_outbox o JOIN players p ON p.id = o.player_id
|
||||
WHERE o.sent_at IS NULL AND o.failed_at IS NULL AND p.deleted_at IS NULL ORDER BY o.created_at LIMIT ?`).all(limit)
|
||||
.map((row) => ({ id: row.id, content: row.content, attempts: row.attempts, discordId: row.discord_id }));
|
||||
const pending = () => this.db.prepare(`SELECT o.id, o.kind, o.content, o.attempts, p.discord_id, a.group_opened, a.expedition_returned FROM alert_outbox o
|
||||
JOIN players p ON p.id = o.player_id LEFT JOIN player_alerts a ON a.player_id = o.player_id
|
||||
WHERE o.sent_at IS NULL AND o.failed_at IS NULL AND p.deleted_at IS NULL ORDER BY o.created_at`).all();
|
||||
const drop = this.db.prepare("UPDATE alert_outbox SET failed_at = ?, last_error = ? WHERE id = ?");
|
||||
const wanted = [];
|
||||
this.cards.database.transaction(() => {
|
||||
const active = this.alertsActive();
|
||||
for (const row of pending()) {
|
||||
const allowed = row.kind === "group_opened" ? row.group_opened : row.kind === "expedition_returned" ? row.expedition_returned : 0;
|
||||
if (!active) drop.run(this.now(), "alerts disabled", row.id);
|
||||
else if (!allowed) drop.run(this.now(), "player opted out", row.id);
|
||||
else if (wanted.length < limit) wanted.push({ id: row.id, content: row.content, attempts: row.attempts, discordId: row.discord_id });
|
||||
}
|
||||
});
|
||||
return wanted;
|
||||
},
|
||||
|
||||
markAlertSent(id) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue