1
0
mirror of https://github.com/matrix-org/matrix-js-sdk.git synced 2025-08-06 12:02:40 +03:00

Read receipt accumulation for threads (#2881)

This commit is contained in:
Germain
2022-11-16 10:58:42 +00:00
committed by GitHub
parent 45e19e51c1
commit ca2ae24d46
8 changed files with 151 additions and 60 deletions

View File

@@ -364,6 +364,63 @@ describe("SyncAccumulator", function() {
});
});
it("should accumulate threaded read receipts", () => {
const receipt1 = {
type: "m.receipt",
room_id: "!foo:bar",
content: {
"$event1:localhost": {
[ReceiptType.Read]: {
"@alice:localhost": { ts: 1, thread_id: "main" },
},
},
},
};
const receipt2 = {
type: "m.receipt",
room_id: "!foo:bar",
content: {
"$event2:localhost": {
[ReceiptType.Read]: {
"@alice:localhost": { ts: 2, thread_id: "$123" }, // does not clobbers event1 receipt
},
},
},
};
sa.accumulate(syncSkeleton({
ephemeral: {
events: [receipt1],
},
}));
sa.accumulate(syncSkeleton({
ephemeral: {
events: [receipt2],
},
}));
expect(
sa.getJSON().roomsData.join["!foo:bar"].ephemeral.events.length,
).toEqual(1);
expect(
sa.getJSON().roomsData.join["!foo:bar"].ephemeral.events[0],
).toEqual({
type: "m.receipt",
room_id: "!foo:bar",
content: {
"$event1:localhost": {
[ReceiptType.Read]: {
"@alice:localhost": { ts: 1, thread_id: "main" },
},
},
"$event2:localhost": {
[ReceiptType.Read]: {
"@alice:localhost": { ts: 2, thread_id: "$123" },
},
},
},
});
});
describe("summary field", function() {
function createSyncResponseWithSummary(summary) {
return {