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
*/
getLastSinceTime(tabId: TabId) {
const timestamps = this.getTimestamps(this.logs.get(tabId).join("\n"));
let stamp = new Date(0);
if (timestamps) {
stamp = new Date(timestamps.slice(-1)[0]);
stamp.setSeconds(stamp.getSeconds() + 1); // avoid duplicates from last second
}
const logs = this.logs.get(tabId);
const timestamps = this.getTimestamps(logs[logs.length - 1]);
const stamp = new Date(timestamps[0]);
stamp.setSeconds(stamp.getSeconds() + 1); // avoid duplicates from last second
return stamp.toISOString();
}

View File

@ -208,7 +208,7 @@ export class PodLogs extends React.Component<Props> {
renderControls() {
if (!this.ready) return null;
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 (
<div className="controls flex gaps align-center">
<span><Trans>Container</Trans></span>
@ -220,10 +220,10 @@ export class PodLogs extends React.Component<Props> {
autoConvertOptions={false}
/>
<div className="time-range">
{timestamps && (
{since && (
<>
<Trans>Since</Trans>{" "}
<b>{new Date(timestamps[0]).toLocaleString()}</b>
<b>{new Date(since[0]).toLocaleString()}</b>
</>
)}
</div>