Skip to content
This repository was archived by the owner on Sep 11, 2024. It is now read-only.

Commit 79d9a0c

Browse files
authored
Fix soft-crash when hanging up Jitsi via PIP (#7645)
1 parent 038f67e commit 79d9a0c

File tree

2 files changed

+13
-18
lines changed

2 files changed

+13
-18
lines changed

src/components/views/voip/CallView/CallViewHeader.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,7 @@ const CallViewHeader: React.FC<CallViewHeaderProps> = ({
7575
onPipMouseDown,
7676
}) => {
7777
const [callRoom, onHoldCallRoom] = callRooms;
78-
const callRoomName = callRoom.name;
79-
const { roomId } = callRoom;
78+
const { roomId, name: callRoomName } = callRoom;
8079

8180
if (!pipMode) {
8281
return <div className="mx_CallViewHeader">

src/components/views/voip/PipView.tsx

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -199,10 +199,7 @@ export default class PipView extends React.Component<IProps, IState> {
199199
};
200200

201201
private onActiveWidgetStoreUpdate = (): void => {
202-
this.setState({
203-
persistentWidgetId: ActiveWidgetStore.instance.getPersistentWidgetId(),
204-
});
205-
this.updateShowWidgetInPip();
202+
this.updateShowWidgetInPip(ActiveWidgetStore.instance.getPersistentWidgetId());
206203
};
207204

208205
private updateCalls = (): void => {
@@ -237,24 +234,23 @@ export default class PipView extends React.Component<IProps, IState> {
237234
}
238235
};
239236

240-
public updateShowWidgetInPip() {
241-
const wId = this.state.persistentWidgetId;
242-
237+
// Accepts a persistentWidgetId to be able to skip awaiting the setState for persistentWidgetId
238+
public updateShowWidgetInPip(persistentWidgetId = this.state.persistentWidgetId) {
243239
let userIsPartOfTheRoom = false;
244240
let fromAnotherRoom = false;
245241
let notVisible = false;
246-
if (wId) {
247-
const persistentWidgetInRoomId = ActiveWidgetStore.instance.getRoomId(wId);
242+
if (persistentWidgetId) {
243+
const persistentWidgetInRoomId = ActiveWidgetStore.instance.getRoomId(persistentWidgetId);
248244
const persistentWidgetInRoom = MatrixClientPeg.get().getRoom(persistentWidgetInRoomId);
249245

250246
// Sanity check the room - the widget may have been destroyed between render cycles, and
251247
// thus no room is associated anymore.
252-
if (!persistentWidgetInRoom) return null;
253-
254-
const wls = WidgetLayoutStore.instance;
255-
notVisible = !wls.isVisibleOnScreen(persistentWidgetInRoom, wId);
256-
userIsPartOfTheRoom = persistentWidgetInRoom.getMyMembership() == "join";
257-
fromAnotherRoom = this.state.viewedRoomId !== persistentWidgetInRoomId;
248+
if (persistentWidgetInRoom) {
249+
const wls = WidgetLayoutStore.instance;
250+
notVisible = !wls.isVisibleOnScreen(persistentWidgetInRoom, persistentWidgetId);
251+
userIsPartOfTheRoom = persistentWidgetInRoom.getMyMembership() == "join";
252+
fromAnotherRoom = this.state.viewedRoomId !== persistentWidgetInRoomId;
253+
}
258254
}
259255

260256
// The widget should only be shown as a persistent app (in a floating pip container) if it is not visible on screen
@@ -263,7 +259,7 @@ export default class PipView extends React.Component<IProps, IState> {
263259
(fromAnotherRoom && userIsPartOfTheRoom) ||
264260
(notVisible && userIsPartOfTheRoom);
265261

266-
this.setState({ showWidgetInPip });
262+
this.setState({ showWidgetInPip, persistentWidgetId });
267263
}
268264

269265
public render() {

0 commit comments

Comments
 (0)