diff --git a/frontend/src/stores.js b/frontend/src/stores.js index d31729d..3305f87 100644 --- a/frontend/src/stores.js +++ b/frontend/src/stores.js @@ -174,7 +174,9 @@ class MessageStore extends Store { } _recomputeMessages() { - this.value = this.value.map((e, i) => this._processMessage(e, this.value[i - 1])); + for (let i = 0; i < this.value.length; i++) { + this.value[i] = this._processMessage(this.value[i], this.value[i - 1]); + } } _processMessage(message, previous=null) { @@ -262,10 +264,11 @@ class MessageStore extends Store { if (!this.isCollectingOldMessages) return false; - const target = 50; + const target = 25; const delta = this.value.length - target; if (delta >= 1) { this.value.splice(0, delta); + this._recomputeMessages(); this.updated(); return true; } else { @@ -291,12 +294,8 @@ class MessageStore extends Store { if (beforeCommitToStore) beforeCommitToStore(res.json); res.json.reverse(); - for (let i = 0; i < res.json.length; i++) { - const message = res.json[i]; - const previous = res.json[i - 1]; - res.json[i] = this._processMessage(message, previous); - } this.value = res.json.concat(this.value); + this._recomputeMessages(); this.updated(); } else { overlayStore.toast("Messages failed to load");