Map live view: names no longer stick to finished strokes when drawing quickly
With line, arrow, circle and area, the stroke being saved stayed the current draft until the save finished, and every mouse movement in that moment sent it live again - after "saved" had gone out. The others then saw the stroke with the drawer's name again until the bot dropped it after 20 s. Drawing quickly (short breaks between strokes) hit this almost every time. - A stroke that is being saved no longer follows the mouse and is never sent live again; the live service also ignores updates for strokes it has already ended. - Viewers remember finished strokes and ignore late updates for them. If someone leaves in the middle of a stroke (reason "left"), the others reload once to get what was saved meanwhile. - The bot (live_tactics.py) ignores late updates of finished strokes too, which also covers browsers still running the previous map version - deployed on 2026-09-25. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
df656209c9
commit
d984918b8c
3 changed files with 32 additions and 8 deletions
|
|
@ -45,6 +45,7 @@ class TacticController {
|
|||
});
|
||||
this.liveClients = []; // offene Verbindungen (je Tab) laut Verteiler
|
||||
this.liveDrafts = new Map(); // "conn|id" -> Strich eines anderen, der gerade entsteht
|
||||
this.liveFinished = new Map(); // "conn|id" -> fertige Striche anderer (Nachzuegler zaehlen nicht mehr)
|
||||
this.liveFocus = null; // zuletzt gemeldeter eigener Schritt
|
||||
this.lastLoadAt = 0;
|
||||
this.reloadTimer = null;
|
||||
|
|
@ -396,6 +397,7 @@ class TacticController {
|
|||
if (tacticId !== this.live.tacticId) {
|
||||
this.liveClients = [];
|
||||
this.liveDrafts.clear();
|
||||
this.liveFinished.clear();
|
||||
this.liveFocus = null;
|
||||
this.live.join(tacticId);
|
||||
}
|
||||
|
|
@ -441,6 +443,8 @@ class TacticController {
|
|||
|
||||
case 'draft': {
|
||||
const draftKey = key(event.conn, event.id);
|
||||
// Nachzuegler eines schon gespeicherten oder abgebrochenen Strichs: nicht wieder anzeigen
|
||||
if (this.liveFinished.has(draftKey)) return;
|
||||
const known = this.liveDrafts.get(draftKey);
|
||||
if (event.append) {
|
||||
// Nachschub zu einem unbekannten Strich: der naechste volle Stand kommt noch
|
||||
|
|
@ -455,14 +459,14 @@ class TacticController {
|
|||
}
|
||||
|
||||
case 'draft_end':
|
||||
if (this.liveDrafts.delete(key(event.conn, event.id))) {
|
||||
this.renderLive();
|
||||
this.requestRedraw();
|
||||
}
|
||||
this.finishLiveDraft(key(event.conn, event.id));
|
||||
// Mitten im Strich gegangen (Tab zu, andere Taktik): was er bis dahin gespeichert hat,
|
||||
// kam evtl. nicht mehr live an - frisch laden
|
||||
if (event.reason === 'left') this.scheduleReload(1000);
|
||||
break;
|
||||
|
||||
case 'shape_added': {
|
||||
if (event.draft) this.liveDrafts.delete(key(event.conn, event.draft));
|
||||
if (event.draft) this.finishLiveDraft(key(event.conn, event.draft));
|
||||
const step = stepOf(event.step);
|
||||
if (!step) {
|
||||
this.scheduleReload(); // ein Schritt, den wir noch nicht kennen
|
||||
|
|
@ -494,6 +498,16 @@ class TacticController {
|
|||
}
|
||||
}
|
||||
|
||||
/** Strich eines anderen ist fertig (gespeichert oder abgebrochen): weg damit und merken, dass er fertig ist. */
|
||||
finishLiveDraft(draftKey) {
|
||||
this.liveFinished.set(draftKey, true);
|
||||
if (this.liveFinished.size > 200) this.liveFinished.delete(this.liveFinished.keys().next().value);
|
||||
if (this.liveDrafts.delete(draftKey)) {
|
||||
this.renderLive();
|
||||
this.requestRedraw();
|
||||
}
|
||||
}
|
||||
|
||||
/** Wer gerade live dabei ist - je Mitglied einmal (auch mit mehreren Tabs), man selbst zuerst. */
|
||||
liveUsers() {
|
||||
const me = this.live.ticket ? this.live.ticket.user_id : null;
|
||||
|
|
@ -854,7 +868,7 @@ class TacticController {
|
|||
sendDraft() {
|
||||
const draft = this.draft;
|
||||
const step = this.currentStep();
|
||||
if (!draft || !step || !this.live.canDraw()) return;
|
||||
if (!draft || draft.saving || !step || !this.live.canDraw()) return;
|
||||
draft.liveSent = true;
|
||||
this.live.updateDraft(draft.liveId, step.id,
|
||||
{ type: draft.type, color: draft.color, width: draft.width, label: draft.label },
|
||||
|
|
@ -952,7 +966,9 @@ class TacticController {
|
|||
}
|
||||
return;
|
||||
}
|
||||
if (!this.draft) return;
|
||||
// Ein abgeschlossener Strich wird gerade gespeichert - er folgt der Maus nicht mehr (und geht
|
||||
// live nicht noch einmal raus, sonst taucht er bei den anderen nach dem Speichern wieder auf).
|
||||
if (!this.draft || this.draft.saving) return;
|
||||
|
||||
const point = this.worldAt(event);
|
||||
const points = this.draft.points;
|
||||
|
|
@ -963,6 +979,8 @@ class TacticController {
|
|||
points[points.length - 1] = point;
|
||||
} else if (this.drawing) {
|
||||
points[1] = point;
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
this.sendDraft();
|
||||
this.redraw();
|
||||
|
|
|
|||
|
|
@ -28,6 +28,7 @@ class TacticLiveService {
|
|||
|
||||
this.outbox = []; // Ereignisse in Reihenfolge, die noch raus muessen
|
||||
this.draft = null; // Strich, der gerade entsteht (wird gebuendelt verschickt)
|
||||
this.endedIds = []; // zuletzt abgeschlossene Striche - die gehen nie wieder raus
|
||||
this.sending = false;
|
||||
this.flushTimer = null;
|
||||
this.lastSend = 0;
|
||||
|
|
@ -54,6 +55,7 @@ class TacticLiveService {
|
|||
this.conn = null;
|
||||
this.outbox = [];
|
||||
this.draft = null;
|
||||
this.endedIds = [];
|
||||
this.sending = false;
|
||||
this.retryDelay = 1000;
|
||||
this.setStatus('off');
|
||||
|
|
@ -187,7 +189,8 @@ class TacticLiveService {
|
|||
* nur der Nachschub raus; sonst (Linie, Pfeil, Kreis, Flaeche) immer der ganze Strich.
|
||||
*/
|
||||
updateDraft(id, stepId, shape, points, growing) {
|
||||
if (!this.tacticId) return;
|
||||
// Nachzuegler eines schon abgeschlossenen Strichs (z.B. Mausbewegung waehrend des Speicherns)
|
||||
if (!this.tacticId || this.endedIds.includes(id)) return;
|
||||
if (!this.draft || this.draft.id !== id) {
|
||||
this.materializeDraft();
|
||||
this.draft = { id, sent: 0 };
|
||||
|
|
@ -202,6 +205,8 @@ class TacticLiveService {
|
|||
this.materializeDraft();
|
||||
this.draft = null;
|
||||
}
|
||||
this.endedIds.push(id);
|
||||
if (this.endedIds.length > 50) this.endedIds.shift();
|
||||
if (cancelled) this.push({ type: 'draft_end', id });
|
||||
else this.schedule();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -28,6 +28,7 @@ const PATCHNOTES = [
|
|||
['type' => 'neu', 'area' => 'Karte', 'text' => 'Live-Ansicht: Öffnest du eine Taktik, siehst du jeden Strich der anderen, während er gezeichnet wird - mit dem Namen an der Stiftspitze. Gespeicherte und gelöschte Zeichnungen, neue Schritte und Änderungen erscheinen sofort, ohne Neuladen.'],
|
||||
['type' => 'neu', 'area' => 'Karte', 'text' => 'Mehrere können gleichzeitig in derselben Taktik zeichnen, auch im selben Schritt. Jeder nimmt mit „Rückgängig“ nur seine eigenen Striche zurück.'],
|
||||
['type' => 'neu', 'area' => 'Karte', 'text' => 'Im Taktik-Fenster steht, wer gerade dabei ist; ein Punkt in der Schrittliste zeigt, wer in welchem Schritt ist, und blinkt, solange dort gezeichnet wird. Ein Klick auf einen Namen springt in dessen Schritt - praktisch im Raid, um dem Raid-Lead zu folgen.'],
|
||||
['type' => 'behoben', 'area' => 'Karte', 'text' => 'Wer schnell hintereinander Linien, Pfeile oder Kreise zeichnete, dessen Name blieb bei den anderen noch eine Weile an den fertigen Strichen stehen - er verschwindet jetzt sofort.'],
|
||||
],
|
||||
],
|
||||
[
|
||||
|
|
|
|||
Loading…
Reference in a new issue