1
0
mirror of https://github.com/lensapp/lens.git synced 2025-05-20 05:10:56 +00:00

move null handling to public method

Signed-off-by: Sebastian Malton <sebastian@malton.name>
This commit is contained in:
Sebastian Malton 2021-03-11 09:10:02 -05:00
parent cd97869375
commit 1d21176064
2 changed files with 7 additions and 12 deletions

View File

@ -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

View File

@ -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) ?? [];
}
/**