Merge pull request #4606 from matrix-org/t3chguy/peeking-races
Fix room alias lookup vs peeking race condition
This commit is contained in:
commit
0fd5714e21
2 changed files with 22 additions and 14 deletions
|
@ -164,6 +164,8 @@ export default createReactClass({
|
||||||
|
|
||||||
canReact: false,
|
canReact: false,
|
||||||
canReply: false,
|
canReply: false,
|
||||||
|
|
||||||
|
matrixClientIsReady: this.context && this.context.isInitialSyncComplete(),
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -232,7 +234,8 @@ export default createReactClass({
|
||||||
initialEventId: RoomViewStore.getInitialEventId(),
|
initialEventId: RoomViewStore.getInitialEventId(),
|
||||||
isInitialEventHighlighted: RoomViewStore.isInitialEventHighlighted(),
|
isInitialEventHighlighted: RoomViewStore.isInitialEventHighlighted(),
|
||||||
forwardingEvent: RoomViewStore.getForwardingEvent(),
|
forwardingEvent: RoomViewStore.getForwardingEvent(),
|
||||||
shouldPeek: RoomViewStore.shouldPeek(),
|
// we should only peek once we have a ready client
|
||||||
|
shouldPeek: this.state.matrixClientIsReady && RoomViewStore.shouldPeek(),
|
||||||
showingPinned: SettingsStore.getValue("PinnedEvents.isOpen", roomId),
|
showingPinned: SettingsStore.getValue("PinnedEvents.isOpen", roomId),
|
||||||
showReadReceipts: SettingsStore.getValue("showReadReceipts", roomId),
|
showReadReceipts: SettingsStore.getValue("showReadReceipts", roomId),
|
||||||
};
|
};
|
||||||
|
@ -681,6 +684,16 @@ export default createReactClass({
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case 'sync_state':
|
||||||
|
if (!this.state.matrixClientIsReady) {
|
||||||
|
this.setState({
|
||||||
|
matrixClientIsReady: this.context && this.context.isInitialSyncComplete(),
|
||||||
|
}, () => {
|
||||||
|
// send another "initial" RVS update to trigger peeking if needed
|
||||||
|
this._onRoomViewStoreUpdate(true);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -1663,14 +1676,16 @@ export default createReactClass({
|
||||||
const ErrorBoundary = sdk.getComponent("elements.ErrorBoundary");
|
const ErrorBoundary = sdk.getComponent("elements.ErrorBoundary");
|
||||||
|
|
||||||
if (!this.state.room) {
|
if (!this.state.room) {
|
||||||
const loading = this.state.roomLoading || this.state.peekLoading;
|
const loading = !this.state.matrixClientIsReady || this.state.roomLoading || this.state.peekLoading;
|
||||||
if (loading) {
|
if (loading) {
|
||||||
|
// Assume preview loading if we don't have a ready client or a room ID (still resolving the alias)
|
||||||
|
const previewLoading = !this.state.matrixClientIsReady || !this.state.roomId || this.state.peekLoading;
|
||||||
return (
|
return (
|
||||||
<div className="mx_RoomView">
|
<div className="mx_RoomView">
|
||||||
<ErrorBoundary>
|
<ErrorBoundary>
|
||||||
<RoomPreviewBar
|
<RoomPreviewBar
|
||||||
canPreview={false}
|
canPreview={false}
|
||||||
previewLoading={this.state.peekLoading}
|
previewLoading={previewLoading && !this.state.roomLoadError}
|
||||||
error={this.state.roomLoadError}
|
error={this.state.roomLoadError}
|
||||||
loading={loading}
|
loading={loading}
|
||||||
joining={this.state.joining}
|
joining={this.state.joining}
|
||||||
|
@ -1695,7 +1710,8 @@ export default createReactClass({
|
||||||
return (
|
return (
|
||||||
<div className="mx_RoomView">
|
<div className="mx_RoomView">
|
||||||
<ErrorBoundary>
|
<ErrorBoundary>
|
||||||
<RoomPreviewBar onJoinClick={this.onJoinButtonClicked}
|
<RoomPreviewBar
|
||||||
|
onJoinClick={this.onJoinButtonClicked}
|
||||||
onForgetClick={this.onForgetClick}
|
onForgetClick={this.onForgetClick}
|
||||||
onRejectClick={this.onRejectThreepidInviteButtonClicked}
|
onRejectClick={this.onRejectThreepidInviteButtonClicked}
|
||||||
canPreview={false} error={this.state.roomLoadError}
|
canPreview={false} error={this.state.roomLoadError}
|
||||||
|
|
|
@ -46,7 +46,6 @@ const INITIAL_STATE = {
|
||||||
forwardingEvent: null,
|
forwardingEvent: null,
|
||||||
|
|
||||||
quotingEvent: null,
|
quotingEvent: null,
|
||||||
matrixClientIsReady: false,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -60,9 +59,6 @@ class RoomViewStore extends Store {
|
||||||
|
|
||||||
// Initialise state
|
// Initialise state
|
||||||
this._state = INITIAL_STATE;
|
this._state = INITIAL_STATE;
|
||||||
if (MatrixClientPeg.get()) {
|
|
||||||
this._state.matrixClientIsReady = MatrixClientPeg.get().isInitialSyncComplete();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
_setState(newState) {
|
_setState(newState) {
|
||||||
|
@ -157,11 +153,6 @@ class RoomViewStore extends Store {
|
||||||
}, /*className=*/null, /*isPriority=*/false, /*isStatic=*/true);
|
}, /*className=*/null, /*isPriority=*/false, /*isStatic=*/true);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 'sync_state':
|
|
||||||
this._setState({
|
|
||||||
matrixClientIsReady: MatrixClientPeg.get() && MatrixClientPeg.get().isInitialSyncComplete(),
|
|
||||||
});
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -224,6 +215,7 @@ class RoomViewStore extends Store {
|
||||||
storeRoomAliasInCache(payload.room_alias, result.room_id);
|
storeRoomAliasInCache(payload.room_alias, result.room_id);
|
||||||
roomId = result.room_id;
|
roomId = result.room_id;
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
|
console.error("RVS failed to get room id for alias: ", err);
|
||||||
dis.dispatch({
|
dis.dispatch({
|
||||||
action: 'view_room_error',
|
action: 'view_room_error',
|
||||||
room_id: null,
|
room_id: null,
|
||||||
|
@ -374,7 +366,7 @@ class RoomViewStore extends Store {
|
||||||
}
|
}
|
||||||
|
|
||||||
shouldPeek() {
|
shouldPeek() {
|
||||||
return this._state.shouldPeek && this._state.matrixClientIsReady;
|
return this._state.shouldPeek;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue