Add 'cancel all' option to 'unsent messages' bar

Also, make sure we hide said bar when unsent messages are cancelled.
This commit is contained in:
Richard van der Hoff 2016-03-21 16:49:07 +00:00
parent 11be2e1cad
commit 75f8765f88
3 changed files with 25 additions and 3 deletions

View file

@ -36,5 +36,9 @@ module.exports = {
removeFromQueue: function(event) { removeFromQueue: function(event) {
MatrixClientPeg.get().cancelPendingEvent(event); MatrixClientPeg.get().cancelPendingEvent(event);
dis.dispatch({
action: 'message_send_cancelled',
event: event
});
}, },
}; };

View file

@ -49,6 +49,10 @@ module.exports = React.createClass({
// 'unsent messages' bar // 'unsent messages' bar
onResendAllClick: React.PropTypes.func, onResendAllClick: React.PropTypes.func,
// callback for when the user clicks on the 'cancel all' button in the
// 'unsent messages' bar
onCancelAllClick: React.PropTypes.func,
// callback for when the user clicks on the 'scroll to bottom' button // callback for when the user clicks on the 'scroll to bottom' button
onScrollToBottomClick: React.PropTypes.func, onScrollToBottomClick: React.PropTypes.func,
@ -223,9 +227,14 @@ module.exports = React.createClass({
</div> </div>
<div className="mx_RoomStatusBar_connectionLostBar_desc"> <div className="mx_RoomStatusBar_connectionLostBar_desc">
<a className="mx_RoomStatusBar_resend_link" <a className="mx_RoomStatusBar_resend_link"
onClick={ this.props.onResendAllClick }> onClick={ this.props.onResendAllClick }>
Resend all now Resend all
</a> or select individual messages to re-send. </a> or <a
className="mx_RoomStatusBar_resend_link"
onClick={ this.props.onCancelAllClick }>
cancel all
</a> now. You can also select individual messages to
resend or cancel.
</div> </div>
</div> </div>
); );

View file

@ -214,6 +214,7 @@ module.exports = React.createClass({
switch (payload.action) { switch (payload.action) {
case 'message_send_failed': case 'message_send_failed':
case 'message_sent': case 'message_sent':
case 'message_send_cancelled':
this.setState({ this.setState({
hasUnsentMessages: this._hasUnsentMessages(this.state.room) hasUnsentMessages: this._hasUnsentMessages(this.state.room)
}); });
@ -501,6 +502,13 @@ module.exports = React.createClass({
}); });
}, },
onCancelAllClick: function() {
var eventsToResend = this._getUnsentMessages(this.state.room);
eventsToResend.forEach(function(event) {
Resend.removeFromQueue(event);
});
},
onJoinButtonClicked: function(ev) { onJoinButtonClicked: function(ev) {
var self = this; var self = this;
@ -1209,6 +1217,7 @@ module.exports = React.createClass({
atEndOfLiveTimeline={this.state.atEndOfLiveTimeline} atEndOfLiveTimeline={this.state.atEndOfLiveTimeline}
hasActiveCall={inCall} hasActiveCall={inCall}
onResendAllClick={this.onResendAllClick} onResendAllClick={this.onResendAllClick}
onCancelAllClick={this.onCancelAllClick}
onScrollToBottomClick={this.jumpToLiveTimeline} onScrollToBottomClick={this.jumpToLiveTimeline}
onResize={this.onChildResize} onResize={this.onChildResize}
/> />