Skip to content

Commit 92b2e34

Browse files
committed
Fixed another bug born from the history refactor
1 parent 58da2f8 commit 92b2e34

File tree

2 files changed

+15
-10
lines changed

2 files changed

+15
-10
lines changed

js/History.js

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -32,17 +32,22 @@ class History {
3232

3333
add(node) {
3434
const id = node.id;
35-
// Most of the time we're dealing with new nodes which we can push to the front more efficiently
36-
if (this._order.length && node.createdTime >= this.last.createdTime) {
37-
this._order.push(node);
38-
} else {
39-
// Otherwise we've probably wound up loading an old node, so start from the back and work forwards, checking created time to determine insert point
40-
for (let nodeIndex = 0; nodeIndex < this._order.length; nodeIndex++) {
41-
if (node.createdTime < this._order[nodeIndex].createdTime) {
42-
this._order.splice(nodeIndex, 0, node);
43-
break;
35+
if (this._order.length) {
36+
// Most of the time we're dealing with new nodes which we can push to the front more efficiently
37+
if (node.createdTime >= this.last.createdTime) {
38+
this._order.push(node);
39+
} else {
40+
// Otherwise we've probably wound up loading an old node, so start from the back and work forwards, checking created time to determine insert point
41+
for (let nodeIndex = 0; nodeIndex < this._order.length; nodeIndex++) {
42+
if (node.createdTime < this._order[nodeIndex].createdTime) {
43+
this._order.splice(nodeIndex, 0, node);
44+
break;
45+
}
4446
}
4547
}
48+
} else {
49+
// If this is the first node just jam it in
50+
this._order.push(node);
4651
}
4752
this._content.set(id, node);
4853
this._cull();

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "akun-api",
3-
"version": "4.0.2",
3+
"version": "4.0.3",
44
"description": "A module intended to enable easy interactions with Anonkun",
55
"main": "index.js",
66
"type": "module",

0 commit comments

Comments
 (0)