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

Fix room joining spinner being incorrect if you change room mid-join #7473

Merged
merged 1 commit into from
Jan 7, 2022
Merged
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: 10 additions & 6 deletions src/stores/RoomViewStore.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,9 @@ class RoomViewStore extends Store<ActionPayload> {
this.joinRoomError(payload);
break;
case Action.JoinRoomReady:
this.setState({ shouldPeek: false });
if (this.state.roomId === payload.roomId) {
this.setState({ shouldPeek: false });
}
break;
case 'on_client_not_viable':
case 'on_logged_out':
Expand Down Expand Up @@ -279,7 +281,9 @@ class RoomViewStore extends Store<ActionPayload> {
});

const cli = MatrixClientPeg.get();
const address = this.state.roomAlias || this.state.roomId;
// take a copy of roomAlias & roomId as they may change by the time the join is complete
const { roomAlias, roomId } = this.state;
const address = roomAlias || roomId;
const viaServers = this.state.viaServers || [];
try {
await retry<any, MatrixError>(() => cli.joinRoom(address, {
Expand All @@ -289,19 +293,19 @@ class RoomViewStore extends Store<ActionPayload> {
// if we received a Gateway timeout then retry
return err.httpStatus === 504;
});
CountlyAnalytics.instance.trackRoomJoin(startTime, this.state.roomId, payload._type);
CountlyAnalytics.instance.trackRoomJoin(startTime, roomId, payload._type);

// We do *not* clear the 'joining' flag because the Room object and/or our 'joined' member event may not
// have come down the sync stream yet, and that's the point at which we'd consider the user joined to the
// room.
dis.dispatch({
action: Action.JoinRoomReady,
roomId: this.state.roomId,
roomId,
});
} catch (err) {
dis.dispatch({
action: Action.JoinRoomError,
roomId: this.state.roomId,
roomId,
err: err,
});
}
Expand Down Expand Up @@ -354,7 +358,7 @@ class RoomViewStore extends Store<ActionPayload> {
joining: false,
joinError: payload.err,
});
this.showJoinRoomError(payload.err, this.state.roomId);
this.showJoinRoomError(payload.err, payload.roomId);
}

public reset() {
Expand Down