1
0
mirror of https://github.com/matrix-org/matrix-react-sdk.git synced 2025-11-07 10:46:24 +03:00

Merge pull request #3406 from matrix-org/t3chguy/reply_to_search_results

Fix replying from search results for this and all rooms
This commit is contained in:
Michael Telatynski
2019-09-11 17:14:55 +01:00
committed by GitHub
3 changed files with 30 additions and 7 deletions

View File

@@ -37,18 +37,19 @@ export default class ReplyPreview extends React.Component {
constructor(props, context) {
super(props, context);
this.unmounted = false;
this.state = {
event: null,
event: RoomViewStore.getQuotingEvent(),
};
this._onRoomViewStoreUpdate = this._onRoomViewStoreUpdate.bind(this);
this._roomStoreToken = RoomViewStore.addListener(this._onRoomViewStoreUpdate);
this._onRoomViewStoreUpdate();
}
componentWillUnmount() {
this.unmounted = true;
// Remove RoomStore listener
if (this._roomStoreToken) {
this._roomStoreToken.remove();
@@ -56,6 +57,8 @@ export default class ReplyPreview extends React.Component {
}
_onRoomViewStoreUpdate() {
if (this.unmounted) return;
const event = RoomViewStore.getQuotingEvent();
if (this.state.event !== event) {
this.setState({ event });