You've already forked matrix-js-sdk
mirror of
https://github.com/matrix-org/matrix-js-sdk.git
synced 2025-11-23 17:02:25 +03:00
Remove knock state on join (#4977)
Signed-off-by: Svajunas Budrys <svajunas.budrys.sb@gmail.com>
This commit is contained in:
@@ -571,6 +571,49 @@ describe("SyncAccumulator", function () {
|
|||||||
expect(sa.getJSON().roomsData.knock["!knock:bar"]).toBeUndefined();
|
expect(sa.getJSON().roomsData.knock["!knock:bar"]).toBeUndefined();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("should delete knock state when room transitions from knock to join", () => {
|
||||||
|
const initKnockState = makeKnockState();
|
||||||
|
sa.accumulate(
|
||||||
|
syncSkeleton(
|
||||||
|
{},
|
||||||
|
{},
|
||||||
|
{},
|
||||||
|
{
|
||||||
|
knock_state: initKnockState,
|
||||||
|
},
|
||||||
|
),
|
||||||
|
);
|
||||||
|
expect(sa.getJSON().roomsData.knock["!knock:bar"].knock_state).toBe(initKnockState);
|
||||||
|
|
||||||
|
// Room transitions from knock to join (e.g., after approval and joining)
|
||||||
|
const joinState = {
|
||||||
|
account_data: { events: [] },
|
||||||
|
ephemeral: { events: [] },
|
||||||
|
unread_notifications: {},
|
||||||
|
state: {
|
||||||
|
events: [member("bob", KnownMembership.Join)],
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
const syncResponse = {
|
||||||
|
next_batch: "abc",
|
||||||
|
rooms: {
|
||||||
|
join: {
|
||||||
|
"!knock:bar": joinState,
|
||||||
|
},
|
||||||
|
invite: {},
|
||||||
|
leave: {},
|
||||||
|
},
|
||||||
|
} as unknown as ISyncResponse;
|
||||||
|
|
||||||
|
sa.accumulate(syncResponse);
|
||||||
|
|
||||||
|
expect(sa.getJSON().roomsData.knock["!knock:bar"]).toBeUndefined();
|
||||||
|
expect(sa.getJSON().roomsData.join["!knock:bar"].state?.events[0]?.content.membership).toEqual(
|
||||||
|
KnownMembership.Join,
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
it("should accumulate read receipts", () => {
|
it("should accumulate read receipts", () => {
|
||||||
const receipt1 = {
|
const receipt1 = {
|
||||||
type: "m.receipt",
|
type: "m.receipt",
|
||||||
|
|||||||
@@ -317,7 +317,10 @@ export class SyncAccumulator {
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case Category.Join:
|
case Category.Join:
|
||||||
if (this.inviteRooms[roomId]) {
|
if (this.knockRooms[roomId]) {
|
||||||
|
// delete knock state on join
|
||||||
|
delete this.knockRooms[roomId];
|
||||||
|
} else if (this.inviteRooms[roomId]) {
|
||||||
// (1)
|
// (1)
|
||||||
// was previously invite, now join. We expect /sync to give
|
// was previously invite, now join. We expect /sync to give
|
||||||
// the entire state and timeline on 'join', so delete previous
|
// the entire state and timeline on 'join', so delete previous
|
||||||
|
|||||||
Reference in New Issue
Block a user