From dfa27e2c0ddbc0d552567d09871baffd18e43b23 Mon Sep 17 00:00:00 2001 From: Eli Bosley Date: Wed, 18 Dec 2024 12:53:00 -0500 Subject: [PATCH] fix: improve typing and format lookup --- web/components/Notifications/Item.vue | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/web/components/Notifications/Item.vue b/web/components/Notifications/Item.vue index 6325ba4a9..3f834b0b6 100644 --- a/web/components/Notifications/Item.vue +++ b/web/components/Notifications/Item.vue @@ -64,16 +64,18 @@ const mutationError = computed(() => { return archive.error?.message ?? deleteNotification.error?.message; }); -const reformattedTimestamp = computed(() => { +const reformattedTimestamp = computed(() => { + if (!props.timestamp) return ''; const userLocale = navigator.language ?? 'en-US'; // Get the user's browser language (e.g., 'en-US', 'fr-FR') const reformattedDate = new Intl.DateTimeFormat(userLocale, { + localeMatcher: 'best fit', month: 'short', day: 'numeric', hour: '2-digit', minute: '2-digit', - hour12: ['AM', 'PM'].some(period => (props.formattedTimestamp ?? 'AM').includes(period)) - }).format(new Date(props.timestamp ?? new Date())); + hour12: ['AM', 'PM'].some((period) => (props.formattedTimestamp ?? 'AM').includes(period)), + }).format(new Date(props.timestamp)); return reformattedDate; }); @@ -81,7 +83,9 @@ const reformattedTimestamp = computed(() => {