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

A bit of cleaning up

Signed-off-by: Alex Andreev <alex.andreev.email@gmail.com>
This commit is contained in:
Alex Andreev 2020-10-11 16:04:31 +03:00
parent a58915ca96
commit b5c0fbb3fc

View File

@ -18,8 +18,8 @@ export interface IPodLogsData {
type TabId = string; type TabId = string;
interface PodLogs { interface PodLogs {
oldLogs: string oldLogs?: string
newLogs: string newLogs?: string
} }
@autobind() @autobind()
@ -67,26 +67,21 @@ export class PodLogsStore extends DockTabStore<IPodLogsData> {
tailLines: tailLines, tailLines: tailLines,
}); });
if (!oldLogs) { if (!oldLogs) {
this.update(tabId, loadedLogs); this.logs.set(tabId, { oldLogs: loadedLogs, newLogs });
} else { } else {
this.update(tabId, "", `${newLogs}\n${loadedLogs}`.trim()); this.logs.set(tabId, { oldLogs, newLogs: loadedLogs });
} }
} catch (error) { } catch (error) {
this.update(tabId, [ this.logs.set(tabId, {
_i18n._(t`Failed to load logs: ${error.message}`), oldLogs: [
_i18n._(t`Reason: ${error.reason} (${error.code})`), _i18n._(t`Failed to load logs: ${error.message}`),
].join("\n")); _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) { getTimestamps(logs: string) {
return logs.match(/^\d+\S+/gm); return logs.match(/^\d+\S+/gm);
} }