Refactor remove resend_all_events and cancel_all_events dispatches

This commit is contained in:
Luke Barnard 2017-02-27 13:39:12 +00:00
parent b68b0e25c8
commit 7221900497
4 changed files with 17 additions and 28 deletions

View file

@ -20,6 +20,20 @@ var sdk = require('./index');
var Modal = require('./Modal');
module.exports = {
resendUnsentEvents: function(room) {
room.getPendingEvents().filter(function(ev) {
return ev.status === Matrix.EventStatus.NOT_SENT;
}).forEach(function(event) {
module.exports.resend(event);
});
},
cancelUnsentEvents: function(room) {
room.getPendingEvents().filter(function(ev) {
return ev.status === Matrix.EventStatus.NOT_SENT;
}).forEach(function(event) {
module.exports.removeFromQueue(event);
});
},
resend: function(event) {
const room = MatrixClientPeg.get().getRoom(event.getRoomId());
MatrixClientPeg.get().resendEvent(
@ -47,7 +61,6 @@ module.exports = {
});
});
},
removeFromQueue: function(event) {
MatrixClientPeg.get().cancelPendingEvent(event);
dis.dispatch({