svelte-log-view 6.3.2 → 6.3.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/LogView.svelte +16 -22
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "svelte-log-view",
3
- "version": "6.3.2",
3
+ "version": "6.3.4",
4
4
  "publishConfig": {
5
5
  "access": "public",
6
6
  "provenance": true
@@ -41,6 +41,9 @@
41
41
  let current;
42
42
  if (entries.length > 0) {
43
43
  current = entries[entries.length - 1];
44
+ if (follow) {
45
+ setSelected(entries.length - 1);
46
+ }
44
47
  }
45
48
 
46
49
  do {
@@ -73,22 +76,16 @@
73
76
  }
74
77
 
75
78
  if (selected < 0) {
76
- const cursor = entries[0];
79
+ const additionalEntries = [];
77
80
 
78
- for (let i = 0; i < fetchAboveRows; i++) {
79
- entries.unshift();
81
+ for await (const entry of source.fetch(entries[0], -fetchAboveRows, fetchAboveRows)) {
82
+ additionalEntries.push(entry);
80
83
  }
81
84
 
82
- selected += fetchAboveRows;
83
- offsetRows += fetchAboveRows;
85
+ entries.unshift(...additionalEntries);
84
86
 
85
- let i = 0;
86
- for await (const entry of source.fetch(cursor, -fetchAboveRows, fetchAboveRows)) {
87
- entries[i++] = entry;
88
- if (i >= fetchAboveRows) {
89
- break;
90
- }
91
- }
87
+ selected += additionalEntries.length;
88
+ offsetRows += additionalEntries.length;
92
89
  }
93
90
 
94
91
  if (selected < offsetRows) {
@@ -103,17 +100,14 @@
103
100
  }
104
101
 
105
102
  function setFollow(flag) {
106
- if (follow === flag) {
107
- return;
108
- }
109
-
110
- if (flag) {
111
- fetchFollow();
112
- } else {
113
- source.abort();
103
+ if (follow !== flag) {
104
+ follow = flag;
105
+ if (flag) {
106
+ fetchFollow();
107
+ } else {
108
+ source.abort();
109
+ }
114
110
  }
115
-
116
- follow = flag;
117
111
  }
118
112
 
119
113
  function onkeydown(event) {