1
0
mirror of https://github.com/matrix-org/matrix-js-sdk.git synced 2025-12-23 22:42:10 +03:00

Fix event removal

This commit is contained in:
David Baker
2015-11-05 14:13:52 +00:00
parent ad80d4f059
commit 856c34016d

View File

@@ -285,17 +285,17 @@ Room.prototype.addEvents = function(events, duplicateStrategy) {
*/
Room.prototype.removeEvents = function(event_ids) {
// avoids defining a function in the loop, which is a lint error
function eq(a, b) {
return a === b;
}
for (var i = 0; i < event_ids.length; ++i) {
function remove_event_with_id(timeline, id) {
// NB. we supply reverse to search from the end,
// on the assumption that recents events are much
// more likley to be removed than older ones.
var removed = utils.removeElement(
this.timeline, eq.bind(event_ids[i]), true
);
return utils.removeElement(timeline, function(e) {
return e.getId() == id;
}, true);
}
for (var i = 0; i < event_ids.length; ++i) {
var removed = remove_event_with_id(this.timeline, event_ids[i]);
if (removed !== false) {
this.emit("Room.timeline", removed, this, undefined, true);
}