You've already forked matrix-react-sdk
mirror of
https://github.com/matrix-org/matrix-react-sdk.git
synced 2025-07-28 15:22:05 +03:00
Fix call splitbrains when switching between rooms (#9692)
* Fix call splitbrains when switching between rooms Mounting CallView causes the user's call membership room state to be cleaned up. However, because the GroupCall object always thought the local device was disconnected from the call, it would remove the local device from room state when the clean method is called, causing a splitbrain. This uses GroupCall's new enteredViaAnotherSession field to fix that, and also simplify participant tracking. * Remove clean tests that have been moved to matrix-js-sdk
This commit is contained in:
@ -939,96 +939,6 @@ describe("ElementCall", () => {
|
||||
|
||||
call.off(CallEvent.Destroy, onDestroy);
|
||||
});
|
||||
|
||||
describe("clean", () => {
|
||||
const aliceWeb: IMyDevice = {
|
||||
device_id: "aliceweb",
|
||||
last_seen_ts: 0,
|
||||
};
|
||||
const aliceDesktop: IMyDevice = {
|
||||
device_id: "alicedesktop",
|
||||
last_seen_ts: 0,
|
||||
};
|
||||
const aliceDesktopOffline: IMyDevice = {
|
||||
device_id: "alicedesktopoffline",
|
||||
last_seen_ts: 1000 * 60 * 60 * -2, // 2 hours ago
|
||||
};
|
||||
const aliceDesktopNeverOnline: IMyDevice = {
|
||||
device_id: "alicedesktopneveronline",
|
||||
};
|
||||
|
||||
const mkContent = (devices: IMyDevice[]) => ({
|
||||
"m.calls": [{
|
||||
"m.call_id": call.groupCall.groupCallId,
|
||||
"m.devices": devices.map(d => ({
|
||||
device_id: d.device_id, session_id: "1", feeds: [], expires_ts: 1000 * 60 * 10,
|
||||
})),
|
||||
}],
|
||||
});
|
||||
const expectDevices = (devices: IMyDevice[]) => expect(
|
||||
room.currentState.getStateEvents(ElementCall.MEMBER_EVENT_TYPE.name, alice.userId)?.getContent(),
|
||||
).toEqual({
|
||||
"m.calls": [{
|
||||
"m.call_id": call.groupCall.groupCallId,
|
||||
"m.devices": devices.map(d => ({
|
||||
device_id: d.device_id, session_id: "1", feeds: [], expires_ts: expect.any(Number),
|
||||
})),
|
||||
}],
|
||||
});
|
||||
|
||||
beforeEach(() => {
|
||||
client.getDeviceId.mockReturnValue(aliceWeb.device_id);
|
||||
client.getDevices.mockResolvedValue({
|
||||
devices: [
|
||||
aliceWeb,
|
||||
aliceDesktop,
|
||||
aliceDesktopOffline,
|
||||
aliceDesktopNeverOnline,
|
||||
],
|
||||
});
|
||||
});
|
||||
|
||||
it("doesn't clean up valid devices", async () => {
|
||||
await client.sendStateEvent(
|
||||
room.roomId,
|
||||
ElementCall.MEMBER_EVENT_TYPE.name,
|
||||
mkContent([aliceDesktop]),
|
||||
alice.userId,
|
||||
);
|
||||
|
||||
await call.clean();
|
||||
expectDevices([aliceDesktop]);
|
||||
});
|
||||
|
||||
it("cleans up our own device if we're disconnected", async () => {
|
||||
await client.sendStateEvent(
|
||||
room.roomId,
|
||||
ElementCall.MEMBER_EVENT_TYPE.name,
|
||||
mkContent([aliceWeb, aliceDesktop]),
|
||||
alice.userId,
|
||||
);
|
||||
|
||||
await call.clean();
|
||||
expectDevices([aliceDesktop]);
|
||||
});
|
||||
|
||||
it("cleans up devices that have never been online", async () => {
|
||||
await client.sendStateEvent(
|
||||
room.roomId,
|
||||
ElementCall.MEMBER_EVENT_TYPE.name,
|
||||
mkContent([aliceDesktop, aliceDesktopNeverOnline]),
|
||||
alice.userId,
|
||||
);
|
||||
|
||||
await call.clean();
|
||||
expectDevices([aliceDesktop]);
|
||||
});
|
||||
|
||||
it("no-ops if there are no state events", async () => {
|
||||
await call.clean();
|
||||
expect(room.currentState.getStateEvents(JitsiCall.MEMBER_EVENT_TYPE, alice.userId)).toBe(null);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe("instance in a video room", () => {
|
||||
|
Reference in New Issue
Block a user