allow for sending arbitrary events, also override highlight with

event currently being forwarded while forwardingEvent is set

Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>
This commit is contained in:
Michael Telatynski 2017-05-19 01:29:11 +01:00
parent 475646a2a7
commit cc7edbf86d
2 changed files with 12 additions and 10 deletions

View file

@ -125,7 +125,7 @@ module.exports = React.createClass({
roomId: null, roomId: null,
roomLoading: true, roomLoading: true,
forwardingMessage: null, forwardingEvent: null,
editingRoomSettings: false, editingRoomSettings: false,
uploadingRoomSettings: false, uploadingRoomSettings: false,
numUnreadMessages: 0, numUnreadMessages: 0,
@ -454,9 +454,9 @@ module.exports = React.createClass({
}); });
break; break;
case 'forward_message': case 'forward_event':
this.setState({ this.setState({
forwardingMessage: payload.content, forwardingEvent: payload.content,
}); });
break; break;
} }
@ -1203,7 +1203,7 @@ module.exports = React.createClass({
this.updateTint(); this.updateTint();
this.setState({ this.setState({
editingRoomSettings: false, editingRoomSettings: false,
forwardingMessage: null, forwardingEvent: null,
}); });
dis.dispatch({action: 'focus_composer'}); dis.dispatch({action: 'focus_composer'});
}, },
@ -1621,8 +1621,8 @@ module.exports = React.createClass({
} }
let aux = null; let aux = null;
if (this.state.forwardingMessage !== null) { if (this.state.forwardingEvent !== null) {
aux = <ForwardMessage onCancelClick={this.onCancelClick} currentRoomId={this.state.room.roomId} content={this.state.forwardingMessage} />; aux = <ForwardMessage onCancelClick={this.onCancelClick} currentRoomId={this.state.room.roomId} mxEvent={this.state.forwardingEvent} />;
} else if (this.state.editingRoomSettings) { } else if (this.state.editingRoomSettings) {
aux = <RoomSettings ref="room_settings" onSaveClick={this.onSettingsSaveClick} onCancelClick={this.onCancelClick} room={this.state.room} />; aux = <RoomSettings ref="room_settings" onSaveClick={this.onSettingsSaveClick} onCancelClick={this.onCancelClick} room={this.state.room} />;
} else if (this.state.uploadingRoomSettings) { } else if (this.state.uploadingRoomSettings) {
@ -1742,14 +1742,13 @@ module.exports = React.createClass({
} }
// console.log("ShowUrlPreview for %s is %s", this.state.room.roomId, this.state.showUrlPreview); // console.log("ShowUrlPreview for %s is %s", this.state.room.roomId, this.state.showUrlPreview);
var messagePanel = ( var messagePanel = (
<TimelinePanel ref={this._gatherTimelinePanelRef} <TimelinePanel ref={this._gatherTimelinePanelRef}
timelineSet={this.state.room.getUnfilteredTimelineSet()} timelineSet={this.state.room.getUnfilteredTimelineSet()}
manageReadReceipts={!UserSettingsStore.getSyncedSetting('hideReadReceipts', false)} manageReadReceipts={!UserSettingsStore.getSyncedSetting('hideReadReceipts', false)}
manageReadMarkers={true} manageReadMarkers={true}
hidden={hideMessagePanel} hidden={hideMessagePanel}
highlightedEventId={this.props.highlightedEventId} highlightedEventId={this.state.forwardingEvent ? this.state.forwardingEvent.getId() : this.props.highlightedEventId}
eventId={this.props.eventId} eventId={this.props.eventId}
eventPixelOffset={this.props.eventPixelOffset} eventPixelOffset={this.props.eventPixelOffset}
onScroll={ this.onMessageListScroll } onScroll={ this.onMessageListScroll }

View file

@ -26,7 +26,9 @@ module.exports = React.createClass({
propTypes: { propTypes: {
currentRoomId: React.PropTypes.string.isRequired, currentRoomId: React.PropTypes.string.isRequired,
content: React.PropTypes.object.isRequired,
/* the MatrixEvent to be forwarded */
mxEvent: React.PropTypes.object.isRequired,
onCancelClick: React.PropTypes.func.isRequired, onCancelClick: React.PropTypes.func.isRequired,
}, },
@ -57,8 +59,9 @@ module.exports = React.createClass({
onAction: function(payload) { onAction: function(payload) {
if (payload.action === 'view_room') { if (payload.action === 'view_room') {
const event = this.props.mxEvent;
const Client = MatrixClientPeg.get(); const Client = MatrixClientPeg.get();
Client.sendMessage(payload.room_id, this.props.content).done(() => { Client.sendEvent(payload.room_id, event.getType(), event.getContent()).done(() => {
dis.dispatch({action: 'message_sent'}); dis.dispatch({action: 'message_sent'});
}, (err) => { }, (err) => {
if (err.name === "UnknownDeviceError") { if (err.name === "UnknownDeviceError") {