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

Remove async call to get virtual room from room load #9743

Merged
merged 4 commits into from
Dec 13, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions src/components/structures/RoomView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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
// the RoomView instance
if (initial) {
const virtualRoom = newState.roomId
? await VoipUserMapper.sharedInstance().getVirtualRoomForRoom(newState.roomId)
: undefined;

newState.room = this.context.client!.getRoom(newState.roomId) || undefined;
newState.virtualRoom = virtualRoom || undefined;
if (newState.room) {
newState.showApps = this.shouldShowApps(newState.room);
this.onRoomLoaded(newState.room);
Expand Down Expand Up @@ -1208,6 +1203,12 @@ export class RoomView extends React.Component<IRoomProps, IRoomState> {
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,
// after a successful peek, or after we join the room).
private onRoomLoaded = (room: Room) => {
Expand All @@ -1222,6 +1223,7 @@ export class RoomView extends React.Component<IRoomProps, IRoomState> {
this.updateE2EStatus(room);
this.updatePermissions(room);
this.checkWidgets(room);
this.loadVirtualRoom(room);

if (
this.getMainSplitContentType(room) !== MainSplitContentType.Timeline &&
Expand Down Expand Up @@ -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) {
return;
}
Expand All @@ -1301,11 +1303,9 @@ export class RoomView extends React.Component<IRoomProps, IRoomState> {
);
}

const virtualRoom = await VoipUserMapper.sharedInstance().getVirtualRoomForRoom(room.roomId);
this.setState(
{
room: room,
virtualRoom: virtualRoom || undefined,
},
() => {
this.onRoomLoaded(room);
Expand Down
4 changes: 4 additions & 0 deletions src/components/structures/TimelinePanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -342,12 +342,16 @@ class TimelinePanel extends React.Component<IProps, IState> {
const differentEventId = prevProps.eventId != this.props.eventId;
const differentHighlightedEventId = prevProps.highlightedEventId != this.props.highlightedEventId;
const differentAvoidJump = prevProps.eventScrollIntoView && !this.props.eventScrollIntoView;
const differentOverlayTimeline = prevProps.overlayTimelineSet !== this.props.overlayTimelineSet;
if (differentEventId || differentHighlightedEventId || differentAvoidJump) {
logger.log(
`TimelinePanel switching to eventId ${this.props.eventId} (was ${prevProps.eventId}), ` +
`scrollIntoView: ${this.props.eventScrollIntoView} (was ${prevProps.eventScrollIntoView})`,
);
this.initTimeline(this.props);
} else if (differentOverlayTimeline) {
logger.log(`TimelinePanel updating overlay timeline.`);
this.initTimeline(this.props);
}
}

Expand Down