diff --git a/src/renderer/components/dock/pod-log-controls.tsx b/src/renderer/components/dock/pod-log-controls.tsx index f73e3a50cb..7e8d046ed2 100644 --- a/src/renderer/components/dock/pod-log-controls.tsx +++ b/src/renderer/components/dock/pod-log-controls.tsx @@ -22,9 +22,9 @@ interface Props extends PodLogSearchProps { export const PodLogControls = observer((props: Props) => { if (!props.ready) return null; - const { tabData, tabId, save, reload, logs } = props; + const { tabData, save, reload, logs } = props; const { selectedContainer, showTimestamps, previous } = tabData; - const since = podLogsStore.getTimestamps(podLogsStore.logs.get(tabId)[0]); + const since = logs.length ? podLogsStore.getTimestamps(logs[0]) : null; const pod = new Pod(tabData.pod); const toggleTimestamps = () => { diff --git a/src/renderer/components/dock/pod-logs.store.ts b/src/renderer/components/dock/pod-logs.store.ts index 075b1241b0..6895fb0e24 100644 --- a/src/renderer/components/dock/pod-logs.store.ts +++ b/src/renderer/components/dock/pod-logs.store.ts @@ -5,7 +5,6 @@ import { DockTabStore } from "./dock-tab.store"; import { dockStore, IDockTab, TabKind } from "./dock.store"; import { t } from "@lingui/macro"; import { _i18n } from "../../i18n"; -import { isDevelopment } from "../../../common/vars"; import { searchStore } from "./search.store"; export interface IPodLogsData { @@ -21,7 +20,7 @@ type TabId = string; type PodLogLine = string; // Number for log lines to load -export const logRange = 1000; +export const logRange = 500; @autobind() export class PodLogsStore extends DockTabStore { @@ -90,6 +89,7 @@ export class PodLogsStore extends DockTabStore { * @param tabId */ loadMore = async (tabId: TabId) => { + if (!this.logs.get(tabId).length) return; const oldLogs = this.logs.get(tabId); const logs = await this.loadLogs(tabId, { sinceTime: this.getLastSinceTime(tabId) @@ -128,7 +128,7 @@ export class PodLogsStore extends DockTabStore { * @param tabId */ setNewLogSince(tabId: TabId) { - if (!this.logs.has(tabId) || this.newLogSince.has(tabId)) return; + if (!this.logs.has(tabId) || !this.logs.get(tabId).length || this.newLogSince.has(tabId)) return; const timestamp = this.getLastSinceTime(tabId); this.newLogSince.set(tabId, timestamp.split(".")[0]); // Removing milliseconds from string } diff --git a/src/renderer/components/dock/pod-logs.tsx b/src/renderer/components/dock/pod-logs.tsx index 8757360883..99d98a94e1 100644 --- a/src/renderer/components/dock/pod-logs.tsx +++ b/src/renderer/components/dock/pod-logs.tsx @@ -212,6 +212,7 @@ export class PodLogs extends React.Component { top: this.logsElement.current.scrollHeight, behavior: "auto" }); + this.showJumpToBottom = false; }} > Jump to bottom @@ -229,7 +230,7 @@ export class PodLogs extends React.Component { } if (!this.logs.length) { return ( -
+
There are no logs available for container.
); @@ -248,6 +249,7 @@ export class PodLogs extends React.Component { onScroll={this.onScroll} outerRef={this.logsElement} ref={this.virtualListRef} + className="box grow" /> ); @@ -276,7 +278,7 @@ export class PodLogs extends React.Component { showSubmitClose={false} showButtons={false} /> -
+
{this.renderJumpToBottom()} {this.renderLogs()}
diff --git a/src/renderer/components/dock/search.store.ts b/src/renderer/components/dock/search.store.ts index 5783fa0d49..f891bdad9e 100644 --- a/src/renderer/components/dock/search.store.ts +++ b/src/renderer/components/dock/search.store.ts @@ -34,7 +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; + if (!text) return []; const occurences: number[] = []; text.forEach((line, index) => { const regex = new RegExp(this.escapeRegex(query), "gi");