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

Remove excessive join('\n\)s

Signed-off-by: Alex Andreev <alex.andreev.email@gmail.com>
This commit is contained in:
Alex Andreev 2020-10-15 14:41:42 +03:00
parent dd8efbc7de
commit 0aee5554b0
2 changed files with 7 additions and 9 deletions

View File

@ -142,12 +142,10 @@ export class PodLogsStore extends DockTabStore<IPodLogsData> {
* @param tabId * @param tabId
*/ */
getLastSinceTime(tabId: TabId) { getLastSinceTime(tabId: TabId) {
const timestamps = this.getTimestamps(this.logs.get(tabId).join("\n")); const logs = this.logs.get(tabId);
let stamp = new Date(0); const timestamps = this.getTimestamps(logs[logs.length - 1]);
if (timestamps) { const stamp = new Date(timestamps[0]);
stamp = new Date(timestamps.slice(-1)[0]); stamp.setSeconds(stamp.getSeconds() + 1); // avoid duplicates from last second
stamp.setSeconds(stamp.getSeconds() + 1); // avoid duplicates from last second
}
return stamp.toISOString(); return stamp.toISOString();
} }

View File

@ -208,7 +208,7 @@ export class PodLogs extends React.Component<Props> {
renderControls() { renderControls() {
if (!this.ready) return null; if (!this.ready) return null;
const { selectedContainer, showTimestamps, previous } = this.tabData; const { selectedContainer, showTimestamps, previous } = this.tabData;
const timestamps = podLogsStore.getTimestamps(podLogsStore.logs.get(this.tabId).join("\n")); const since = podLogsStore.getTimestamps(podLogsStore.logs.get(this.tabId)[0]);
return ( return (
<div className="controls flex gaps align-center"> <div className="controls flex gaps align-center">
<span><Trans>Container</Trans></span> <span><Trans>Container</Trans></span>
@ -220,10 +220,10 @@ export class PodLogs extends React.Component<Props> {
autoConvertOptions={false} autoConvertOptions={false}
/> />
<div className="time-range"> <div className="time-range">
{timestamps && ( {since && (
<> <>
<Trans>Since</Trans>{" "} <Trans>Since</Trans>{" "}
<b>{new Date(timestamps[0]).toLocaleString()}</b> <b>{new Date(since[0]).toLocaleString()}</b>
</> </>
)} )}
</div> </div>