Public: anyone can read this; the crew can change it.

/talk keeps an unsent line across a reload and clears it once sent #14152

Merged opened this

Check · Review · Land · Live done — Landed and live in production.

Merged

torque/forge:torque/14126-talk-keeps-an-unsent-line-across-a-reloa → main 3 commits fork

  • Merged. torque/14126-talk-keeps-an-unsent-line-across-a-reloa was merged into main as c00b436.

Review

Sign in to review this change.
2 files changed +5 −5
src/web/pages/talk_client.ts +4 −4
@@ -130,8 +130,8 @@ if (root) {
130130 jump.addEventListener("click", () => { stuck = true; toEnd(true); box.focus(); });
131131 const draftKey = "talk-draft:" + (root.dataset.user || "") + ":" + (cid || "");
132132 let draftTimer = 0;
133 const saveDraft = () => { clearTimeout(draftTimer); try { if (box.value) localStorage.setItem(draftKey, box.value); else localStorage.removeItem(draftKey); } catch (_) {} };
134 try { if (!box.value) box.value = localStorage.getItem(draftKey) || ""; } catch (_) {}
133 const saveDraft = () => { clearTimeout(draftTimer); try { if (box.value) sessionStorage.setItem(draftKey, box.value); else sessionStorage.removeItem(draftKey); } catch (_) {} };
134 try { if (!box.value) box.value = sessionStorage.getItem(draftKey) || ""; } catch (_) {}
135135 const grow = () => { box.style.height = "auto"; box.style.height = Math.min(box.scrollHeight, window.innerHeight * 0.4) + "px"; };
136136 box.addEventListener("input", () => {
137137 grow();
@@ -325,7 +325,7 @@ if (root) {
325325 const text = box.value.trim();
326326 if (!text) { if (attached.length) say("Add a few words about what you attached."); return; }
327327 if (editing) {
328 if (await again("edit", new URLSearchParams({ text }))) { clearTimeout(draftTimer); try { localStorage.removeItem(draftKey); } catch (_) {} }
328 if (await again("edit", new URLSearchParams({ text }))) { clearTimeout(draftTimer); try { sessionStorage.removeItem(draftKey); } catch (_) {} }
329329 return;
330330 }
331331 const steer = e.submitter === steerBtn;
@@ -346,7 +346,7 @@ if (root) {
346346 chips.replaceChildren();
347347 grow();
348348 clearTimeout(draftTimer);
349 try { localStorage.removeItem(draftKey); } catch (_) {}
349 try { sessionStorage.removeItem(draftKey); } catch (_) {}
350350 stuck = true;
351351 const out = await res.json().catch(() => ({}));
352352 if (out.how === "queued") { say("Queued: it sends after this answer."); if (!source) follow(); return; }
test/talk-page.test.ts +1 −1
@@ -392,7 +392,7 @@ describe("the page", () => {
392392 const nav = { clipboard: { writeText: async (t: string) => { copied.push(t); } } };
393393 class ES { on: Record<string, (e: { data: string }) => void> = {}; constructor() { sources.push(this); } addEventListener(n: string, f: (e: { data: string }) => void) { this.on[n] = f; } close() {} }
394394 doc.getElementById("end").scrollIntoView = () => {};
395 new Function("document", "window", "EventSource", "fetch", "localStorage", "navigator", talkJs)(doc, window, ES, fetchStub, local, nav);
395 new Function("document", "window", "EventSource", "fetch", "sessionStorage", "navigator", talkJs)(doc, window, ES, fetchStub, local, nav);
396396 const box = doc.querySelector("textarea");
397397 const key = (init: object) => box.dispatchEvent(new window.KeyboardEvent("keydown", { key: "Enter", bubbles: true, cancelable: true, ...init }));
398398 const emit = (id: string, html: string) => sources.at(-1)!.on["turn"]!({ data: JSON.stringify({ id, html }) });

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs