Skip to content
Snippets Groups Projects
Commit 2160440f authored by Kegan Dougal's avatar Kegan Dougal
Browse files

Add and impl resend button. Update UI when failing to send messages.

parent e0496305
Branches
Tags
No related merge requests found
...@@ -74,3 +74,7 @@ limitations under the License. ...@@ -74,3 +74,7 @@ limitations under the License.
.mx_MessageTile_highlight { .mx_MessageTile_highlight {
color: #00f; color: #00f;
} }
.mx_MessageTile_msgOption {
float: right;
}
...@@ -57,8 +57,7 @@ module.exports = React.createClass({ ...@@ -57,8 +57,7 @@ module.exports = React.createClass({
mx_MessageTile_continuation: this.props.continuation, mx_MessageTile_continuation: this.props.continuation,
}); });
var timestamp = this.props.last ? <MessageTimestamp ts={this.props.mxEvent.getTs()} /> : null; var timestamp = this.props.last ? <MessageTimestamp ts={this.props.mxEvent.getTs()} /> : null;
var avatar; var avatar, sender, resend;
var sender;
if (!this.props.continuation) { if (!this.props.continuation) {
avatar = ( avatar = (
<div className="mx_MessageTile_avatar"> <div className="mx_MessageTile_avatar">
...@@ -67,10 +66,16 @@ module.exports = React.createClass({ ...@@ -67,10 +66,16 @@ module.exports = React.createClass({
); );
sender = <SenderProfile mxEvent={this.props.mxEvent} />; sender = <SenderProfile mxEvent={this.props.mxEvent} />;
} }
if (this.props.mxEvent.status === "not_sent" && !this.state.resending) {
resend = <button className="mx_MessageTile_msgOption" onClick={this.onResend}>
Resend
</button>;
}
return ( return (
<div className={classes}> <div className={classes}>
{ avatar } { avatar }
{ timestamp } { timestamp }
{ resend }
{ sender } { sender }
<TileType mxEvent={this.props.mxEvent} /> <TileType mxEvent={this.props.mxEvent} />
</div> </div>
......
...@@ -232,6 +232,10 @@ module.exports = { ...@@ -232,6 +232,10 @@ module.exports = {
dis.dispatch({ dis.dispatch({
action: 'message_sent' action: 'message_sent'
}); });
}, function() {
dis.dispatch({
action: 'message_send_failed'
});
}); });
this.refs.textarea.getDOMNode().value = ''; this.refs.textarea.getDOMNode().value = '';
ev.preventDefault(); ev.preventDefault();
......
...@@ -23,6 +23,28 @@ module.exports = { ...@@ -23,6 +23,28 @@ module.exports = {
var actions = MatrixClientPeg.get().getPushActionsForEvent(this.props.mxEvent); var actions = MatrixClientPeg.get().getPushActionsForEvent(this.props.mxEvent);
if (!actions || !actions.tweaks) { return false; } if (!actions || !actions.tweaks) { return false; }
return actions.tweaks.highlight; return actions.tweaks.highlight;
},
getInitialState: function() {
return {
resending: false
};
},
onResend: function() {
var self = this;
self.setState({
resending: true
});
MatrixClientPeg.get().resendEvent(
this.props.mxEvent, MatrixClientPeg.get().getRoom(
this.props.mxEvent.getRoomId()
)
).finally(function() {
self.setState({
resending: false
});
})
} }
}; };
...@@ -79,10 +79,12 @@ module.exports = { ...@@ -79,10 +79,12 @@ module.exports = {
onAction: function(payload) { onAction: function(payload) {
switch (payload.action) { switch (payload.action) {
case 'message_send_failed':
case 'message_sent': case 'message_sent':
this.setState({ this.setState({
room: MatrixClientPeg.get().getRoom(this.props.roomId) room: MatrixClientPeg.get().getRoom(this.props.roomId)
}); });
this.forceUpdate();
break; break;
case'notifier_enabled': case'notifier_enabled':
this.forceUpdate(); this.forceUpdate();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment