web: filter incoming by per-browser peerID, not source label

Old filter hid all source=web messages — meant multiple browsers
couldn't see each other's sends. Now each browser only filters out
its OWN peerID, so iphone↔mbp↔desktop all see each other's clipboard.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
Claude Opus 4.7
2026-05-21 00:48:21 -05:00
parent 137a81c6a8
commit 09355e9914

View File

@@ -147,7 +147,7 @@
const r = await fetch("/api/send", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({ type: "clipboard", text, source: "web" }),
body: JSON.stringify({ type: "clipboard", text, source: "web", from: peerID }),
});
status(r.ok ? "delivered ✓" : "server returned " + r.status, r.ok ? "ok" : "err");
} catch (e) { status("network error", "err"); }
@@ -207,7 +207,7 @@
es.addEventListener("clipboard", (ev) => {
try {
const m = JSON.parse(ev.data);
if (m.source !== "web") {
if (m.from !== peerID) { // hide our own sends, show everyone else
addIncoming(m.text, m.source, m.ts, false);
}
} catch (e) {}