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:
parent
a58915ca96
commit
b5c0fbb3fc
@ -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<IPodLogsData> {
|
||||
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);
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user