mirror of https://github.com/vector-im/riot-web
Fix replying from search results for this and all rooms
Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>pull/21833/head
parent
d8dbe28015
commit
ef2ff31a46
|
@ -586,7 +586,6 @@ module.exports = createReactClass({
|
||||||
return ContentMessages.sharedInstance().sendContentListToRoom(
|
return ContentMessages.sharedInstance().sendContentListToRoom(
|
||||||
[payload.file], this.state.room.roomId, MatrixClientPeg.get(),
|
[payload.file], this.state.room.roomId, MatrixClientPeg.get(),
|
||||||
);
|
);
|
||||||
break;
|
|
||||||
case 'notifier_enabled':
|
case 'notifier_enabled':
|
||||||
case 'upload_started':
|
case 'upload_started':
|
||||||
case 'upload_finished':
|
case 'upload_finished':
|
||||||
|
@ -624,6 +623,11 @@ module.exports = createReactClass({
|
||||||
showApps: payload.show,
|
showApps: payload.show,
|
||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
|
case 'reply_to_event':
|
||||||
|
if (this.state.searchResults && payload.event.getRoomId() === this.state.roomId && !this.unmounted) {
|
||||||
|
this.onCancelSearchClick();
|
||||||
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
|
@ -37,18 +37,19 @@ export default class ReplyPreview extends React.Component {
|
||||||
|
|
||||||
constructor(props, context) {
|
constructor(props, context) {
|
||||||
super(props, context);
|
super(props, context);
|
||||||
|
this.unmounted = false;
|
||||||
|
|
||||||
this.state = {
|
this.state = {
|
||||||
event: null,
|
event: RoomViewStore.getQuotingEvent(),
|
||||||
};
|
};
|
||||||
|
|
||||||
this._onRoomViewStoreUpdate = this._onRoomViewStoreUpdate.bind(this);
|
this._onRoomViewStoreUpdate = this._onRoomViewStoreUpdate.bind(this);
|
||||||
|
|
||||||
this._roomStoreToken = RoomViewStore.addListener(this._onRoomViewStoreUpdate);
|
this._roomStoreToken = RoomViewStore.addListener(this._onRoomViewStoreUpdate);
|
||||||
this._onRoomViewStoreUpdate();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
componentWillUnmount() {
|
componentWillUnmount() {
|
||||||
|
this.unmounted = true;
|
||||||
|
|
||||||
// Remove RoomStore listener
|
// Remove RoomStore listener
|
||||||
if (this._roomStoreToken) {
|
if (this._roomStoreToken) {
|
||||||
this._roomStoreToken.remove();
|
this._roomStoreToken.remove();
|
||||||
|
@ -56,6 +57,8 @@ export default class ReplyPreview extends React.Component {
|
||||||
}
|
}
|
||||||
|
|
||||||
_onRoomViewStoreUpdate() {
|
_onRoomViewStoreUpdate() {
|
||||||
|
if (this.unmounted) return;
|
||||||
|
|
||||||
const event = RoomViewStore.getQuotingEvent();
|
const event = RoomViewStore.getQuotingEvent();
|
||||||
if (this.state.event !== event) {
|
if (this.state.event !== event) {
|
||||||
this.setState({ event });
|
this.setState({ event });
|
||||||
|
|
|
@ -113,9 +113,19 @@ class RoomViewStore extends Store {
|
||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
case 'reply_to_event':
|
case 'reply_to_event':
|
||||||
|
// If currently viewed room does not match the room in which we wish to reply then change rooms
|
||||||
|
// this can happen when performing a search across all rooms
|
||||||
|
if (payload.event && payload.event.getRoomId() !== this._state.roomId) {
|
||||||
|
dis.dispatch({
|
||||||
|
action: 'view_room',
|
||||||
|
room_id: payload.event.getRoomId(),
|
||||||
|
replyingToEvent: payload.event,
|
||||||
|
});
|
||||||
|
} else {
|
||||||
this._setState({
|
this._setState({
|
||||||
replyingToEvent: payload.event,
|
replyingToEvent: payload.event,
|
||||||
});
|
});
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case 'open_room_settings': {
|
case 'open_room_settings': {
|
||||||
const RoomSettingsDialog = sdk.getComponent("dialogs.RoomSettingsDialog");
|
const RoomSettingsDialog = sdk.getComponent("dialogs.RoomSettingsDialog");
|
||||||
|
@ -147,6 +157,11 @@ class RoomViewStore extends Store {
|
||||||
isEditingSettings: false,
|
isEditingSettings: false,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Allow being given an event to be replied to when switching rooms but sanity check its for this room
|
||||||
|
if (payload.replyingToEvent && payload.replyingToEvent.getRoomId() === payload.room_id) {
|
||||||
|
newState.replyingToEvent = payload.replyingToEvent;
|
||||||
|
}
|
||||||
|
|
||||||
if (this._state.forwardingEvent) {
|
if (this._state.forwardingEvent) {
|
||||||
dis.dispatch({
|
dis.dispatch({
|
||||||
action: 'send_event',
|
action: 'send_event',
|
||||||
|
|
Loading…
Reference in New Issue