v4: a new link between two dumps shows among their related dumps at once — it showed on the next load of the page: the backlink service recorded the link without telling anyone, and the dump page fetched its related dumps once, the socket then only editing or removing the ones it had. relinkBacklinks now sends dump_related_changed when a note or a comment gains or loses a link, naming the dump and those at the other end, and the page showing one of them fetches /related again. A link shows to those who may see both its ends, so each socket is told only of the dumps its user may see, and not at all without one at each end. A private dump that turns public sends it too, for the links it already had, which are new to everyone but its poster. The page also fetches its related dumps again on a reconnection, as it does its comments and playlists.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
khannurien
2026-10-10 08:43:55 +00:00
parent dde0232acb
commit 350e945eb1
10 changed files with 221 additions and 8 deletions

View File

@@ -304,6 +304,25 @@ describe("Dump page", () => {
.toBeInTheDocument();
});
test("a new link to or from this dump shows among its related dumps", async () => {
dumpRoutes();
const { socket } = openDump();
await screen.findByRole("heading", { name: "A find" });
expect(screen.queryByRole("heading", { name: "Related" })).toBeNull();
route(
"GET /api/dumps/:id/related",
() => [wire(makeDump({ id: "d2", slug: "linked", title: "Linked" }))],
);
// Links between other dumps leave this page alone.
socket.receive({ type: "dump_related_changed", dumpIds: ["d2", "d3"] });
socket.receive({ type: "dump_related_changed", dumpIds: ["d2", "d1"] });
expect(await screen.findByRole("link", { name: "Linked" }))
.toBeInTheDocument();
expect(screen.getByRole("heading", { name: "Related" }))
.toBeInTheDocument();
expect(calls("GET /api/dumps/:id/related")).toHaveLength(2);
});
test("a dump deleted, or made private, while on screen gives way to a notice", async () => {
dumpRoutes();
const { socket } = openDump(other);