Skip to content
This repository has been archived by the owner on Sep 11, 2024. It is now read-only.

Commit

Permalink
Merge pull request #238 from matrix-org/rav/cancel_sending
Browse files Browse the repository at this point in the history
Add 'cancel all' option to 'unsent messages' bar
  • Loading branch information
richvdh committed Mar 22, 2016
2 parents f6862f0 + 75f8765 commit 74b4547
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 3 deletions.
4 changes: 4 additions & 0 deletions src/Resend.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,5 +36,9 @@ module.exports = {

removeFromQueue: function(event) {
MatrixClientPeg.get().cancelPendingEvent(event);
dis.dispatch({
action: 'message_send_cancelled',
event: event
});
},
};
15 changes: 12 additions & 3 deletions src/components/structures/RoomStatusBar.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,10 @@ module.exports = React.createClass({
// 'unsent messages' bar
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
onScrollToBottomClick: React.PropTypes.func,

Expand Down Expand Up @@ -223,9 +227,14 @@ module.exports = React.createClass({
</div>
<div className="mx_RoomStatusBar_connectionLostBar_desc">
<a className="mx_RoomStatusBar_resend_link"
onClick={ this.props.onResendAllClick }>
Resend all now
</a> or select individual messages to re-send.
onClick={ this.props.onResendAllClick }>
Resend all
</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>
);
Expand Down
9 changes: 9 additions & 0 deletions src/components/structures/RoomView.js
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,7 @@ module.exports = React.createClass({
switch (payload.action) {
case 'message_send_failed':
case 'message_sent':
case 'message_send_cancelled':
this.setState({
hasUnsentMessages: this._hasUnsentMessages(this.state.room)
});
Expand Down Expand Up @@ -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) {
var self = this;

Expand Down Expand Up @@ -1209,6 +1217,7 @@ module.exports = React.createClass({
atEndOfLiveTimeline={this.state.atEndOfLiveTimeline}
hasActiveCall={inCall}
onResendAllClick={this.onResendAllClick}
onCancelAllClick={this.onCancelAllClick}
onScrollToBottomClick={this.jumpToLiveTimeline}
onResize={this.onChildResize}
/>
Expand Down

0 comments on commit 74b4547

Please sign in to comment.