From b5c0fbb3fc9f525219bd57c4c6017988cf3751a9 Mon Sep 17 00:00:00 2001 From: Alex Andreev Date: Sun, 11 Oct 2020 16:04:31 +0300 Subject: [PATCH] A bit of cleaning up Signed-off-by: Alex Andreev --- .../components/dock/pod-logs.store.ts | 27 ++++++++----------- 1 file changed, 11 insertions(+), 16 deletions(-) diff --git a/src/renderer/components/dock/pod-logs.store.ts b/src/renderer/components/dock/pod-logs.store.ts index eaa3c357bd..bf2bf9eb5c 100644 --- a/src/renderer/components/dock/pod-logs.store.ts +++ b/src/renderer/components/dock/pod-logs.store.ts @@ -18,8 +18,8 @@ export interface IPodLogsData { type TabId = string; interface PodLogs { - oldLogs: string - newLogs: string + oldLogs?: string + newLogs?: string } @autobind() @@ -67,26 +67,21 @@ export class PodLogsStore extends DockTabStore { tailLines: tailLines, }); if (!oldLogs) { - this.update(tabId, loadedLogs); + this.logs.set(tabId, { oldLogs: loadedLogs, newLogs }); } else { - this.update(tabId, "", `${newLogs}\n${loadedLogs}`.trim()); + this.logs.set(tabId, { oldLogs, newLogs: loadedLogs }); } } catch (error) { - this.update(tabId, [ - _i18n._(t`Failed to load logs: ${error.message}`), - _i18n._(t`Reason: ${error.reason} (${error.code})`), - ].join("\n")); + this.logs.set(tabId, { + oldLogs: [ + _i18n._(t`Failed to load logs: ${error.message}`), + _i18n._(t`Reason: ${error.reason} (${error.code})`) + ].join("\n"), + newLogs + }); } } - update(tabId: TabId, oldLogs?: string, newLogs?: string) { - const logs = this.logs.get(tabId); - this.logs.set(tabId, { - oldLogs: oldLogs || logs.oldLogs, - newLogs: newLogs || logs.newLogs - }); - } - getTimestamps(logs: string) { return logs.match(/^\d+\S+/gm); }