Skip to content

Commit 42a9ce9

Browse files
committed
Remove unused layout tracking code
1 parent c4b1e0b commit 42a9ce9

File tree

2 files changed

+0
-86
lines changed

2 files changed

+0
-86
lines changed

src/models/Call.ts

Lines changed: 0 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -85,15 +85,9 @@ export enum ConnectionState {
8585
export const isConnected = (state: ConnectionState): boolean =>
8686
state === ConnectionState.Connected || state === ConnectionState.Disconnecting;
8787

88-
export enum Layout {
89-
Tile = "tile",
90-
Spotlight = "spotlight",
91-
}
92-
9388
export enum CallEvent {
9489
ConnectionState = "connection_state",
9590
Participants = "participants",
96-
Layout = "layout",
9791
Close = "close",
9892
Destroy = "destroy",
9993
}
@@ -104,7 +98,6 @@ interface CallEventHandlerMap {
10498
participants: Map<RoomMember, Set<string>>,
10599
prevParticipants: Map<RoomMember, Set<string>>,
106100
) => void;
107-
[CallEvent.Layout]: (layout: Layout) => void;
108101
[CallEvent.Close]: () => void;
109102
[CallEvent.Destroy]: () => void;
110103
}
@@ -658,14 +651,6 @@ export class ElementCall extends Call {
658651

659652
private settingsStoreCallEncryptionWatcher?: string;
660653
private terminationTimer?: number;
661-
private _layout = Layout.Tile;
662-
public get layout(): Layout {
663-
return this._layout;
664-
}
665-
protected set layout(value: Layout) {
666-
this._layout = value;
667-
this.emit(CallEvent.Layout, value);
668-
}
669654

670655
public get presented(): boolean {
671656
return super.presented;
@@ -902,8 +887,6 @@ export class ElementCall extends Call {
902887
audioInput: MediaDeviceInfo | null,
903888
videoInput: MediaDeviceInfo | null,
904889
): Promise<void> {
905-
this.messaging!.on(`action:${ElementWidgetActions.TileLayout}`, this.onTileLayout);
906-
this.messaging!.on(`action:${ElementWidgetActions.SpotlightLayout}`, this.onSpotlightLayout);
907890
this.messaging!.on(`action:${ElementWidgetActions.HangupCall}`, this.onHangup);
908891
this.messaging!.once(`action:${ElementWidgetActions.Close}`, this.onClose);
909892
this.messaging!.on(`action:${ElementWidgetActions.DeviceMute}`, this.onDeviceMute);
@@ -947,8 +930,6 @@ export class ElementCall extends Call {
947930
}
948931

949932
public setDisconnected(): void {
950-
this.messaging!.off(`action:${ElementWidgetActions.TileLayout}`, this.onTileLayout);
951-
this.messaging!.off(`action:${ElementWidgetActions.SpotlightLayout}`, this.onSpotlightLayout);
952933
this.messaging!.off(`action:${ElementWidgetActions.HangupCall}`, this.onHangup);
953934
this.messaging!.off(`action:${ElementWidgetActions.DeviceMute}`, this.onDeviceMute);
954935
super.setDisconnected();
@@ -973,15 +954,6 @@ export class ElementCall extends Call {
973954
if (this.session.memberships.length === 0 && !this.presented && !this.room.isCallRoom()) this.destroy();
974955
};
975956

976-
/**
977-
* Sets the call's layout.
978-
* @param layout The layout to switch to.
979-
*/
980-
public async setLayout(layout: Layout): Promise<void> {
981-
const action = layout === Layout.Tile ? ElementWidgetActions.TileLayout : ElementWidgetActions.SpotlightLayout;
982-
await this.messaging!.transport.send(action, {});
983-
}
984-
985957
private readonly onMembershipChanged = (): void => this.updateParticipants();
986958

987959
private updateParticipants(): void {
@@ -1025,18 +997,6 @@ export class ElementCall extends Call {
1025997
this.close();
1026998
};
1027999

1028-
private readonly onTileLayout = async (ev: CustomEvent<IWidgetApiRequest>): Promise<void> => {
1029-
ev.preventDefault();
1030-
this.layout = Layout.Tile;
1031-
this.messaging!.transport.reply(ev.detail, {}); // ack
1032-
};
1033-
1034-
private readonly onSpotlightLayout = async (ev: CustomEvent<IWidgetApiRequest>): Promise<void> => {
1035-
ev.preventDefault();
1036-
this.layout = Layout.Spotlight;
1037-
this.messaging!.transport.reply(ev.detail, {}); // ack
1038-
};
1039-
10401000
public clean(): Promise<void> {
10411001
return Promise.resolve();
10421002
}

test/unit-tests/models/Call-test.ts

Lines changed: 0 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ import type { Mocked } from "jest-mock";
3434
import type { ClientWidgetApi } from "matrix-widget-api";
3535
import {
3636
type JitsiCallMemberContent,
37-
Layout,
3837
Call,
3938
CallEvent,
4039
ConnectionState,
@@ -941,33 +940,6 @@ describe("ElementCall", () => {
941940
expect(call.connectionState).toBe(ConnectionState.Disconnected);
942941
});
943942

944-
it("tracks layout", async () => {
945-
await callConnectProcedure(call);
946-
expect(call.layout).toBe(Layout.Tile);
947-
948-
messaging.emit(
949-
`action:${ElementWidgetActions.SpotlightLayout}`,
950-
new CustomEvent("widgetapirequest", { detail: {} }),
951-
);
952-
expect(call.layout).toBe(Layout.Spotlight);
953-
954-
messaging.emit(
955-
`action:${ElementWidgetActions.TileLayout}`,
956-
new CustomEvent("widgetapirequest", { detail: {} }),
957-
);
958-
expect(call.layout).toBe(Layout.Tile);
959-
});
960-
961-
it("sets layout", async () => {
962-
await callConnectProcedure(call);
963-
964-
await call.setLayout(Layout.Spotlight);
965-
expect(messaging.transport.send).toHaveBeenCalledWith(ElementWidgetActions.SpotlightLayout, {});
966-
967-
await call.setLayout(Layout.Tile);
968-
expect(messaging.transport.send).toHaveBeenCalledWith(ElementWidgetActions.TileLayout, {});
969-
});
970-
971943
it("acknowledges mute_device widget action", async () => {
972944
await callConnectProcedure(call);
973945
const preventDefault = jest.fn();
@@ -1007,24 +979,6 @@ describe("ElementCall", () => {
1007979
call.off(CallEvent.Participants, onParticipants);
1008980
});
1009981

1010-
it("emits events when layout changes", async () => {
1011-
await callConnectProcedure(call);
1012-
const onLayout = jest.fn();
1013-
call.on(CallEvent.Layout, onLayout);
1014-
1015-
messaging.emit(
1016-
`action:${ElementWidgetActions.SpotlightLayout}`,
1017-
new CustomEvent("widgetapirequest", { detail: {} }),
1018-
);
1019-
messaging.emit(
1020-
`action:${ElementWidgetActions.TileLayout}`,
1021-
new CustomEvent("widgetapirequest", { detail: {} }),
1022-
);
1023-
expect(onLayout.mock.calls).toEqual([[Layout.Spotlight], [Layout.Tile]]);
1024-
1025-
call.off(CallEvent.Layout, onLayout);
1026-
});
1027-
1028982
it("ends the call immediately if the session ended", async () => {
1029983
await callConnectProcedure(call);
1030984
const onDestroy = jest.fn();

0 commit comments

Comments
 (0)