From 198bf792fbf6392983966d5198b0b2d0676a3713 Mon Sep 17 00:00:00 2001 From: DragonBot00 Date: Wed, 1 Apr 2026 14:51:01 -0500 Subject: [PATCH] fix: apply lastReceived field format changes in custom feeds (fixes #5236) --- keep-ui/types/react-table.d.ts | 6 ++++++ .../alerts-table/lib/alert-table-utils.tsx | 15 +++++++++++---- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/keep-ui/types/react-table.d.ts b/keep-ui/types/react-table.d.ts index afaf486849..b38f416c64 100644 --- a/keep-ui/types/react-table.d.ts +++ b/keep-ui/types/react-table.d.ts @@ -1,4 +1,5 @@ import "@tanstack/react-table"; +import { TimeFormatOption } from "@/widgets/alerts-table/lib/alert-table-time-format"; declare module "@tanstack/table-core" { interface ColumnMeta { @@ -7,4 +8,9 @@ declare module "@tanstack/table-core" { sticky?: boolean; align?: "left" | "right" | "center"; } + + interface TableMeta { + columnTimeFormats?: Record; + setColumnTimeFormats?: (formats: Record) => void; + } } diff --git a/keep-ui/widgets/alerts-table/lib/alert-table-utils.tsx b/keep-ui/widgets/alerts-table/lib/alert-table-utils.tsx index 66b8b88114..66550bc47a 100644 --- a/keep-ui/widgets/alerts-table/lib/alert-table-utils.tsx +++ b/keep-ui/widgets/alerts-table/lib/alert-table-utils.tsx @@ -286,9 +286,12 @@ export const useAlertTableCols = ( ? value : new Date(value as string | number); const isoString = date.toISOString(); - // Get the format from column format settings or use default + // Get the format from table meta (backend-synced for custom feeds) or + // fall back to local column time formats, defaulting to "timeago" + const activeColumnTimeFormats = + context.table.options.meta?.columnTimeFormats ?? columnTimeFormats; const formatOption = - columnTimeFormats[context.column.id] || "timeago"; + activeColumnTimeFormats[context.column.id] || "timeago"; return ( {formatDateTime(date, formatOption)} @@ -624,8 +627,12 @@ export const useAlertTableCols = ( const date = value instanceof Date ? value : new Date(value); const isoString = date.toISOString(); - // Get the format from column format settings or use default - const formatOption = columnTimeFormats[context.column.id] || "timeago"; + // Get the format from table meta (backend-synced for custom feeds) or + // fall back to local column time formats, defaulting to "timeago" + const activeColumnTimeFormats = + context.table.options.meta?.columnTimeFormats ?? columnTimeFormats; + const formatOption = + activeColumnTimeFormats[context.column.id] || "timeago"; return ( {formatDateTime(date, formatOption)}