Fix room list often showing the wrong icons for calls (#32881)
* Give rooms with calls a proper accessible description Besides improving accessibility, this makes it possible to check for the presence of a call indicator in the room list in Playwright tests. * Make room list react to calls in a room, even when not connected to them To use the results of CallStore.getRoom reactively, you need to listen for Call events, not ConnectedCalls events. * Don't assume that every call starts off as a video call If a Call object is created by way of someone starting a voice call, then of course the call's initial type needs to be 'voice'. * Make room list items react to changes in call type The type of a call may change over time; therefore room list items explicitly need to react to the changes. * Update a call's type before notifying listeners of the change If we notify listeners of a change in a call's type before actually making that change, the listeners will be working with glitched state. This would cause the room list to show the wrong call type in certain situations. * Ignore the Vitest attachments directory
This commit is contained in:
@@ -108,16 +108,15 @@ export abstract class Call extends TypedEventEmitter<CallEvent, CallEventHandler
|
||||
protected readonly widgetUid: string;
|
||||
protected readonly room: Room;
|
||||
|
||||
private _callType: CallType = CallType.Video;
|
||||
private _callType: CallType;
|
||||
public get callType(): CallType {
|
||||
return this._callType;
|
||||
}
|
||||
|
||||
protected set callType(callType: CallType) {
|
||||
if (this._callType !== callType) {
|
||||
this.emit(CallEvent.CallTypeChanged, callType);
|
||||
}
|
||||
const prevCallType = this._callType;
|
||||
this._callType = callType;
|
||||
if (callType !== prevCallType) this.emit(CallEvent.CallTypeChanged, callType);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -184,11 +183,13 @@ export abstract class Call extends TypedEventEmitter<CallEvent, CallEventHandler
|
||||
*/
|
||||
public readonly widget: IApp,
|
||||
protected readonly client: MatrixClient,
|
||||
initialCallType: CallType,
|
||||
) {
|
||||
super();
|
||||
this.widgetUid = WidgetUtils.getWidgetUid(this.widget);
|
||||
this.room = this.client.getRoom(this.roomId)!;
|
||||
WidgetMessagingStore.instance.on(WidgetMessagingStoreEvent.StopMessaging, this.onStopMessaging);
|
||||
this._callType = initialCallType;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -347,7 +348,7 @@ export class JitsiCall extends Call {
|
||||
private participantsExpirationTimer: number | null = null;
|
||||
|
||||
private constructor(widget: IApp, client: MatrixClient) {
|
||||
super(widget, client);
|
||||
super(widget, client, CallType.Video);
|
||||
|
||||
this.room.on(RoomStateEvent.Update, this.onRoomState);
|
||||
this.on(CallEvent.ConnectionState, this.onConnectionState);
|
||||
@@ -899,7 +900,7 @@ export class ElementCall extends Call {
|
||||
widget: IApp,
|
||||
client: MatrixClient,
|
||||
) {
|
||||
super(widget, client);
|
||||
super(widget, client, session.getConsensusCallIntent() === "audio" ? CallType.Voice : CallType.Video);
|
||||
|
||||
this.session.on(MatrixRTCSessionEvent.MembershipsChanged, this.onMembershipChanged);
|
||||
this.client.matrixRTC.on(MatrixRTCSessionManagerEvents.SessionEnded, this.checkDestroy);
|
||||
|
||||
Reference in New Issue
Block a user