From e86b916415f5bc65ca20af2ebcf000c362a6f84d Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Wed, 19 Apr 2023 08:50:55 +0200 Subject: [PATCH] fix: application logs duplicate --- .../routes/applications/[id]/logs/index.svelte | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/apps/ui/src/routes/applications/[id]/logs/index.svelte b/apps/ui/src/routes/applications/[id]/logs/index.svelte index c52e1d0cf..bf25a8236 100644 --- a/apps/ui/src/routes/applications/[id]/logs/index.svelte +++ b/apps/ui/src/routes/applications/[id]/logs/index.svelte @@ -51,16 +51,22 @@ async function loadLogs() { if (logsLoading) return; try { - const newLogs: any = await get( - `/applications/${id}/logs/${selectedService}?since=${lastLog?.split(' ')[0] || 0}` - ); + const since = lastLog?.split(' ')[0] || 0; + const newLogs: any = await get(`/applications/${id}/logs/${selectedService}?since=${since}`); if (newLogs.noContainer) { noContainer = true; } else { noContainer = false; } if (newLogs?.logs && newLogs.logs[newLogs.logs.length - 1] !== logs[logs.length - 1]) { - logs = logs.concat(newLogs.logs); + if (since === 0) { + logs = logs.concat(newLogs.logs); + } else { + const newParsedLogs = newLogs.logs.filter((log: any) => { + return log !== logs[logs.length - 1]; + }); + logs = logs.concat(newParsedLogs); + } lastLog = newLogs.logs[newLogs.logs.length - 1]; } } catch (error) { @@ -135,7 +141,7 @@ {:else}
-