Remove async call to get virtual room from room load (#9743)
* remove async call to get virtual room from room load * dont init timeline twice when overlay and focused event both change * strict error * prettier
This commit is contained in:
parent
47cc8d6edf
commit
9c5b1f3540
2 changed files with 12 additions and 8 deletions
|
@ -658,12 +658,7 @@ export class RoomView extends React.Component<IRoomProps, IRoomState> {
|
||||||
// NB: This does assume that the roomID will not change for the lifetime of
|
// NB: This does assume that the roomID will not change for the lifetime of
|
||||||
// the RoomView instance
|
// the RoomView instance
|
||||||
if (initial) {
|
if (initial) {
|
||||||
const virtualRoom = newState.roomId
|
|
||||||
? await VoipUserMapper.sharedInstance().getVirtualRoomForRoom(newState.roomId)
|
|
||||||
: undefined;
|
|
||||||
|
|
||||||
newState.room = this.context.client!.getRoom(newState.roomId) || undefined;
|
newState.room = this.context.client!.getRoom(newState.roomId) || undefined;
|
||||||
newState.virtualRoom = virtualRoom || undefined;
|
|
||||||
if (newState.room) {
|
if (newState.room) {
|
||||||
newState.showApps = this.shouldShowApps(newState.room);
|
newState.showApps = this.shouldShowApps(newState.room);
|
||||||
this.onRoomLoaded(newState.room);
|
this.onRoomLoaded(newState.room);
|
||||||
|
@ -1208,6 +1203,12 @@ export class RoomView extends React.Component<IRoomProps, IRoomState> {
|
||||||
return this.messagePanel.canResetTimeline();
|
return this.messagePanel.canResetTimeline();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
private loadVirtualRoom = async (room?: Room): Promise<void> => {
|
||||||
|
const virtualRoom = room?.roomId && (await VoipUserMapper.sharedInstance().getVirtualRoomForRoom(room?.roomId));
|
||||||
|
|
||||||
|
this.setState({ virtualRoom: virtualRoom || undefined });
|
||||||
|
};
|
||||||
|
|
||||||
// called when state.room is first initialised (either at initial load,
|
// called when state.room is first initialised (either at initial load,
|
||||||
// after a successful peek, or after we join the room).
|
// after a successful peek, or after we join the room).
|
||||||
private onRoomLoaded = (room: Room) => {
|
private onRoomLoaded = (room: Room) => {
|
||||||
|
@ -1222,6 +1223,7 @@ export class RoomView extends React.Component<IRoomProps, IRoomState> {
|
||||||
this.updateE2EStatus(room);
|
this.updateE2EStatus(room);
|
||||||
this.updatePermissions(room);
|
this.updatePermissions(room);
|
||||||
this.checkWidgets(room);
|
this.checkWidgets(room);
|
||||||
|
this.loadVirtualRoom(room);
|
||||||
|
|
||||||
if (
|
if (
|
||||||
this.getMainSplitContentType(room) !== MainSplitContentType.Timeline &&
|
this.getMainSplitContentType(room) !== MainSplitContentType.Timeline &&
|
||||||
|
@ -1288,7 +1290,7 @@ export class RoomView extends React.Component<IRoomProps, IRoomState> {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private onRoom = async (room: Room) => {
|
private onRoom = (room: Room) => {
|
||||||
if (!room || room.roomId !== this.state.roomId) {
|
if (!room || room.roomId !== this.state.roomId) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -1301,11 +1303,9 @@ export class RoomView extends React.Component<IRoomProps, IRoomState> {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
const virtualRoom = await VoipUserMapper.sharedInstance().getVirtualRoomForRoom(room.roomId);
|
|
||||||
this.setState(
|
this.setState(
|
||||||
{
|
{
|
||||||
room: room,
|
room: room,
|
||||||
virtualRoom: virtualRoom || undefined,
|
|
||||||
},
|
},
|
||||||
() => {
|
() => {
|
||||||
this.onRoomLoaded(room);
|
this.onRoomLoaded(room);
|
||||||
|
|
|
@ -342,12 +342,16 @@ class TimelinePanel extends React.Component<IProps, IState> {
|
||||||
const differentEventId = prevProps.eventId != this.props.eventId;
|
const differentEventId = prevProps.eventId != this.props.eventId;
|
||||||
const differentHighlightedEventId = prevProps.highlightedEventId != this.props.highlightedEventId;
|
const differentHighlightedEventId = prevProps.highlightedEventId != this.props.highlightedEventId;
|
||||||
const differentAvoidJump = prevProps.eventScrollIntoView && !this.props.eventScrollIntoView;
|
const differentAvoidJump = prevProps.eventScrollIntoView && !this.props.eventScrollIntoView;
|
||||||
|
const differentOverlayTimeline = prevProps.overlayTimelineSet !== this.props.overlayTimelineSet;
|
||||||
if (differentEventId || differentHighlightedEventId || differentAvoidJump) {
|
if (differentEventId || differentHighlightedEventId || differentAvoidJump) {
|
||||||
logger.log(
|
logger.log(
|
||||||
`TimelinePanel switching to eventId ${this.props.eventId} (was ${prevProps.eventId}), ` +
|
`TimelinePanel switching to eventId ${this.props.eventId} (was ${prevProps.eventId}), ` +
|
||||||
`scrollIntoView: ${this.props.eventScrollIntoView} (was ${prevProps.eventScrollIntoView})`,
|
`scrollIntoView: ${this.props.eventScrollIntoView} (was ${prevProps.eventScrollIntoView})`,
|
||||||
);
|
);
|
||||||
this.initTimeline(this.props);
|
this.initTimeline(this.props);
|
||||||
|
} else if (differentOverlayTimeline) {
|
||||||
|
logger.log(`TimelinePanel updating overlay timeline.`);
|
||||||
|
this.initTimeline(this.props);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue