diff --git a/src/common/search-store.ts b/src/common/search-store.ts index 7adb0ef107..c4e34ba5a2 100644 --- a/src/common/search-store.ts +++ b/src/common/search-store.ts @@ -44,14 +44,14 @@ export class SearchStore { * @param query Search query from input */ @action - public onSearch(text: string[], query = this.searchQuery): void { + public onSearch(text?: string[] | null, query = this.searchQuery): void { this.searchQuery = query; if (!query) { return this.reset(); } - this.occurrences = this.findOccurrences(text, query); + this.occurrences = this.findOccurrences(text ?? [], query); if (!this.occurrences.length) { return; @@ -70,8 +70,7 @@ export class SearchStore { * @param query Search query from input * @returns Array of line indexes [0, 0, 14, 17, 17, 17, 20...] */ - private findOccurrences(lines?: string[], query?: string): number[] { - lines ||= []; + private findOccurrences(lines: string[], query?: string): number[] { const regex = new RegExp(SearchStore.escapeRegex(query), "gi"); return lines diff --git a/src/renderer/components/dock/log.store.ts b/src/renderer/components/dock/log.store.ts index 14dc9efdd0..ec80cf4d58 100644 --- a/src/renderer/components/dock/log.store.ts +++ b/src/renderer/components/dock/log.store.ts @@ -59,9 +59,9 @@ export class LogStore { }; /** - * Function is used to refreser/stream-like requests. + * Function is used to refresher/stream-like requests. * It changes 'sinceTime' param each time allowing to fetch logs - * starting from last line recieved. + * starting from last line received. * @param tabId */ loadMore = async (tabId: TabId) => { @@ -91,7 +91,7 @@ export class LogStore { return podsApi.getLogs({ namespace, name }, { ...params, - timestamps: true, // Always setting timestampt to separate old logs from new ones + timestamps: true, // Always setting timestamp to separate old logs from new ones container: selectedContainer.name, previous }).then(result => { @@ -120,11 +120,7 @@ export class LogStore { * Returns logs with timestamps for selected tab */ get logs() { - const id = dockStore.selectedTabId; - - if (!this.podLogs.has(id)) return []; - - return this.podLogs.get(id); + return this.podLogs.get(dockStore.selectedTabId) ?? []; } /**