Skip to content

Commit e18a874

Browse files
committed
fix: improve typing and format lookup
1 parent e5bd1ad commit e18a874

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

web/components/Notifications/Item.vue

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -64,24 +64,28 @@ const mutationError = computed(() => {
6464
return archive.error?.message ?? deleteNotification.error?.message;
6565
});
6666
67-
const reformattedTimestamp = computed(() => {
67+
const reformattedTimestamp = computed<string>(() => {
68+
if (!props.timestamp) return '';
6869
const userLocale = navigator.language ?? 'en-US'; // Get the user's browser language (e.g., 'en-US', 'fr-FR')
6970
7071
const reformattedDate = new Intl.DateTimeFormat(userLocale, {
72+
localeMatcher: 'best fit',
7173
month: 'short',
7274
day: 'numeric',
7375
hour: '2-digit',
7476
minute: '2-digit',
75-
hour12: ['AM', 'PM'].some(period => (props.formattedTimestamp ?? 'AM').includes(period))
76-
}).format(new Date(props.timestamp ?? new Date()));
77+
hour12: ['AM', 'PM'].some((period) => (props.formattedTimestamp ?? 'AM').includes(period)),
78+
}).format(new Date(props.timestamp));
7779
return reformattedDate;
7880
});
7981
</script>
8082

8183
<template>
8284
<div class="group/item relative py-5 flex flex-col gap-2 text-base">
8385
<header class="flex flex-row items-baseline justify-between gap-2 -translate-y-1">
84-
<h3 class="tracking-normal flex flex-row items-baseline gap-2 uppercase font-bold overflow-x-hidden">
86+
<h3
87+
class="tracking-normal flex flex-row items-baseline gap-2 uppercase font-bold overflow-x-hidden"
88+
>
8589
<!-- the `translate` compensates for extra space added by the `svg` element when rendered -->
8690
<component
8791
:is="icon.component"

0 commit comments

Comments
 (0)