mirror of https://github.com/vector-im/riot-web
Fix soft-crash when hanging up Jitsi via PIP (#7645)
parent
038f67e844
commit
79d9a0c0f7
|
@ -75,8 +75,7 @@ const CallViewHeader: React.FC<CallViewHeaderProps> = ({
|
||||||
onPipMouseDown,
|
onPipMouseDown,
|
||||||
}) => {
|
}) => {
|
||||||
const [callRoom, onHoldCallRoom] = callRooms;
|
const [callRoom, onHoldCallRoom] = callRooms;
|
||||||
const callRoomName = callRoom.name;
|
const { roomId, name: callRoomName } = callRoom;
|
||||||
const { roomId } = callRoom;
|
|
||||||
|
|
||||||
if (!pipMode) {
|
if (!pipMode) {
|
||||||
return <div className="mx_CallViewHeader">
|
return <div className="mx_CallViewHeader">
|
||||||
|
|
|
@ -199,10 +199,7 @@ export default class PipView extends React.Component<IProps, IState> {
|
||||||
};
|
};
|
||||||
|
|
||||||
private onActiveWidgetStoreUpdate = (): void => {
|
private onActiveWidgetStoreUpdate = (): void => {
|
||||||
this.setState({
|
this.updateShowWidgetInPip(ActiveWidgetStore.instance.getPersistentWidgetId());
|
||||||
persistentWidgetId: ActiveWidgetStore.instance.getPersistentWidgetId(),
|
|
||||||
});
|
|
||||||
this.updateShowWidgetInPip();
|
|
||||||
};
|
};
|
||||||
|
|
||||||
private updateCalls = (): void => {
|
private updateCalls = (): void => {
|
||||||
|
@ -237,25 +234,24 @@ export default class PipView extends React.Component<IProps, IState> {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
public updateShowWidgetInPip() {
|
// Accepts a persistentWidgetId to be able to skip awaiting the setState for persistentWidgetId
|
||||||
const wId = this.state.persistentWidgetId;
|
public updateShowWidgetInPip(persistentWidgetId = this.state.persistentWidgetId) {
|
||||||
|
|
||||||
let userIsPartOfTheRoom = false;
|
let userIsPartOfTheRoom = false;
|
||||||
let fromAnotherRoom = false;
|
let fromAnotherRoom = false;
|
||||||
let notVisible = false;
|
let notVisible = false;
|
||||||
if (wId) {
|
if (persistentWidgetId) {
|
||||||
const persistentWidgetInRoomId = ActiveWidgetStore.instance.getRoomId(wId);
|
const persistentWidgetInRoomId = ActiveWidgetStore.instance.getRoomId(persistentWidgetId);
|
||||||
const persistentWidgetInRoom = MatrixClientPeg.get().getRoom(persistentWidgetInRoomId);
|
const persistentWidgetInRoom = MatrixClientPeg.get().getRoom(persistentWidgetInRoomId);
|
||||||
|
|
||||||
// Sanity check the room - the widget may have been destroyed between render cycles, and
|
// Sanity check the room - the widget may have been destroyed between render cycles, and
|
||||||
// thus no room is associated anymore.
|
// thus no room is associated anymore.
|
||||||
if (!persistentWidgetInRoom) return null;
|
if (persistentWidgetInRoom) {
|
||||||
|
|
||||||
const wls = WidgetLayoutStore.instance;
|
const wls = WidgetLayoutStore.instance;
|
||||||
notVisible = !wls.isVisibleOnScreen(persistentWidgetInRoom, wId);
|
notVisible = !wls.isVisibleOnScreen(persistentWidgetInRoom, persistentWidgetId);
|
||||||
userIsPartOfTheRoom = persistentWidgetInRoom.getMyMembership() == "join";
|
userIsPartOfTheRoom = persistentWidgetInRoom.getMyMembership() == "join";
|
||||||
fromAnotherRoom = this.state.viewedRoomId !== persistentWidgetInRoomId;
|
fromAnotherRoom = this.state.viewedRoomId !== persistentWidgetInRoomId;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// The widget should only be shown as a persistent app (in a floating pip container) if it is not visible on screen
|
// The widget should only be shown as a persistent app (in a floating pip container) if it is not visible on screen
|
||||||
// either, because we are viewing a different room OR because it is in none of the possible containers of the room view.
|
// either, because we are viewing a different room OR because it is in none of the possible containers of the room view.
|
||||||
|
@ -263,7 +259,7 @@ export default class PipView extends React.Component<IProps, IState> {
|
||||||
(fromAnotherRoom && userIsPartOfTheRoom) ||
|
(fromAnotherRoom && userIsPartOfTheRoom) ||
|
||||||
(notVisible && userIsPartOfTheRoom);
|
(notVisible && userIsPartOfTheRoom);
|
||||||
|
|
||||||
this.setState({ showWidgetInPip });
|
this.setState({ showWidgetInPip, persistentWidgetId });
|
||||||
}
|
}
|
||||||
|
|
||||||
public render() {
|
public render() {
|
||||||
|
|
Loading…
Reference in New Issue