Use two interations instead of while loop for trimming log

FREEBIE
pull/749/head
Scott Nonnenberg 8 years ago
parent 53d1e7e6c7
commit e4ceb21002
No known key found for this signature in database
GPG Key ID: A4931C09644C654B

@ -33,8 +33,14 @@
entry.save();
}
while (this.length > MAX_MESSAGES) {
this.at(0).destroy();
// Two separate iterations to deal with removal eventing wonkiness
var toDrop = this.length - MAX_MESSAGES;
var entries = [];
for (var i = 0; i < toDrop; i += 1) {
entries.push(this.at(i));
}
for (var j = 0, max = entries.length; j < max; j += 1) {
entries[i].destroy();
}
},
print: function() {

Loading…
Cancel
Save