diff --git a/src/renderer/components/dock/pod-logs.store.ts b/src/renderer/components/dock/pod-logs.store.ts index 17cd6f027c..075b1241b0 100644 --- a/src/renderer/components/dock/pod-logs.store.ts +++ b/src/renderer/components/dock/pod-logs.store.ts @@ -21,7 +21,7 @@ type TabId = string; type PodLogLine = string; // Number for log lines to load -export const logRange = isDevelopment ? 100 : 1000; +export const logRange = 1000; @autobind() export class PodLogsStore extends DockTabStore { diff --git a/src/renderer/components/dock/pod-logs.tsx b/src/renderer/components/dock/pod-logs.tsx index 66d5e8fb0b..8757360883 100644 --- a/src/renderer/components/dock/pod-logs.tsx +++ b/src/renderer/components/dock/pod-logs.tsx @@ -140,18 +140,27 @@ export class PodLogs extends React.Component { } onScroll = debounce((props: ListOnScrollProps) => { + if (!this.logsElement.current) return; const toBottomOffset = 100 * lineHeight; // 100 lines * 18px (height of each line) - const { scrollHeight, clientHeight, scrollTop } = this.logsElement.current; - // Trigger loading only if scrolled by user - if (scrollTop === 0 && !props.scrollUpdateWasRequested) { - this.loadMore(); - } - if (scrollHeight - scrollTop > toBottomOffset) { - this.showJumpToBottom = true; + const { scrollHeight, clientHeight } = this.logsElement.current; + const { scrollDirection, scrollOffset, scrollUpdateWasRequested } = props; + if (scrollDirection == "forward") { + if (scrollHeight - scrollOffset < toBottomOffset) { + this.showJumpToBottom = false; + } + if (clientHeight + scrollOffset === scrollHeight) { + this.lastLineIsShown = true; + } } else { - this.showJumpToBottom = false; + this.lastLineIsShown = false; + // Trigger loading only if scrolled by user + if (scrollOffset === 0 && !scrollUpdateWasRequested) { + this.loadMore(); + } + if (scrollHeight - scrollOffset > toBottomOffset) { + this.showJumpToBottom = true; + } } - this.lastLineIsShown = clientHeight + scrollTop === scrollHeight; }, 300); // Debouncing to let virtual list do its internal works /** diff --git a/src/renderer/components/dock/search.store.ts b/src/renderer/components/dock/search.store.ts index 8f1370ba23..5783fa0d49 100644 --- a/src/renderer/components/dock/search.store.ts +++ b/src/renderer/components/dock/search.store.ts @@ -34,6 +34,7 @@ export class SearchStore { * @returns {Array} Array of line indexes [0, 0, 14, 17, 17, 17, 20...] */ findOccurencies(text: string[], query: string) { + if (!text) return; const occurences: number[] = []; text.forEach((line, index) => { const regex = new RegExp(this.escapeRegex(query), "gi");