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:
@@ -55,6 +55,7 @@ function setup({ signedIn = true } = {}) {
|
||||
events: {
|
||||
vote: useEvents("vote"),
|
||||
dump: useEvents("dump"),
|
||||
related: useEvents("related"),
|
||||
playlist: useEvents("playlist"),
|
||||
comment: useEvents("comment"),
|
||||
user: useEvents("user"),
|
||||
@@ -458,6 +459,13 @@ describe("dumps, playlists, comments, users", () => {
|
||||
expect(ws().recentDumps).toEqual([]);
|
||||
});
|
||||
|
||||
test("changed links are passed on as a related event", () => {
|
||||
const { socket, events } = setup();
|
||||
socket.welcome();
|
||||
socket.receive({ type: "dump_related_changed", dumpIds: ["a", "b"] });
|
||||
expect(events().related).toEqual([{ dumpIds: ["a", "b"] }]);
|
||||
});
|
||||
|
||||
test("injectDump adds my own new dump once", () => {
|
||||
const { ws } = setup();
|
||||
const d = makeDump({ id: "mine" });
|
||||
|
||||
Reference in New Issue
Block a user