From a8519050b8754ec62112c2c3a9f1047676e85d7f Mon Sep 17 00:00:00 2001 From: talboren Date: Sun, 11 Feb 2024 15:21:48 +0200 Subject: [PATCH] fix(ui): new Map because Map is immutable (#818) --- keep-ui/app/alerts/alert-assignee.tsx | 5 +++-- keep-ui/app/settings/webhook-settings.tsx | 3 +++ keep-ui/utils/hooks/useAlerts.ts | 8 ++++---- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/keep-ui/app/alerts/alert-assignee.tsx b/keep-ui/app/alerts/alert-assignee.tsx index 04819ae4c..c3dc67627 100644 --- a/keep-ui/app/alerts/alert-assignee.tsx +++ b/keep-ui/app/alerts/alert-assignee.tsx @@ -15,6 +15,7 @@ export default function AlertAssignee({ assignee }: Props) { } const user = users.find((user) => user.email === assignee); + const userName = user?.name || "Keep"; return !imageError ? ( // eslint-disable-next-line @next/next/no-img-element @@ -22,7 +23,7 @@ export default function AlertAssignee({ assignee }: Props) { className="h-8 w-8 rounded-full" src={ user?.picture || - `https://ui-avatars.com/api/?name=${user?.name}&background=random` + `https://ui-avatars.com/api/?name=${userName}&background=random` } height={24} width={24} @@ -32,7 +33,7 @@ export default function AlertAssignee({ assignee }: Props) { /> ) : ( { alertSubscription; useEffect(() => { - const alertsMap = new Map( + const newAlertsMap = new Map( alertsFromEndpoint.map((alertFromEndpoint) => [ alertFromEndpoint.fingerprint, { @@ -113,7 +113,7 @@ export const useAlerts = () => { ]) ); - setAlertsMap(alertsMap); + setAlertsMap(newAlertsMap); }, [alertsFromEndpoint]); useEffect(() => { @@ -133,7 +133,7 @@ export const useAlerts = () => { }, [alertsFromPusher]); return { - data: [...alertsMap.values()], + data: Array.from(alertsMap.values()), ...restOfAlertSubscription, ...restOfAllAlerts, };