File tree Expand file tree Collapse file tree 2 files changed +15
-10
lines changed Expand file tree Collapse file tree 2 files changed +15
-10
lines changed Original file line number Diff line number Diff line change @@ -32,17 +32,22 @@ class History {
32
32
33
33
add ( node ) {
34
34
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
+ }
44
46
}
45
47
}
48
+ } else {
49
+ // If this is the first node just jam it in
50
+ this . _order . push ( node ) ;
46
51
}
47
52
this . _content . set ( id , node ) ;
48
53
this . _cull ( ) ;
Original file line number Diff line number Diff line change 1
1
{
2
2
"name" : " akun-api" ,
3
- "version" : " 4.0.2 " ,
3
+ "version" : " 4.0.3 " ,
4
4
"description" : " A module intended to enable easy interactions with Anonkun" ,
5
5
"main" : " index.js" ,
6
6
"type" : " module" ,
You can’t perform that action at this time.
0 commit comments