diff --git a/web/src/lib/components/comment/comment_card.svelte b/web/src/lib/components/comment/comment_card.svelte index 00de1cf4..819acedf 100644 --- a/web/src/lib/components/comment/comment_card.svelte +++ b/web/src/lib/components/comment/comment_card.svelte @@ -4,6 +4,8 @@ import { createEventDispatcher } from "svelte"; import TextField from "../base/text_field.svelte"; import { fade } from "svelte/transition"; + import { formatTimeSince } from "$lib/util/format_util"; + import { _ } from "svelte-i18n"; export let comment: Comment; export let mode: "show" | "edit" = "show"; @@ -14,10 +16,12 @@ let editedComment = comment.text; - const avatarSrc = comment.expand?.author.avatar + $: avatarSrc = comment.expand?.author.avatar ? getFileURL(comment.expand.author, comment.expand.author.avatar) : `https://api.dicebear.com/7.x/initials/svg?seed=${comment.expand?.author.username ?? ""}&backgroundType=gradientLinear`; + $: timeSince = formatTimeSince(new Date(comment.created ?? "")); + function deleteComment() { dispatch("delete", comment); } @@ -38,8 +42,15 @@ avatar
-

- {comment.expand?.author.username} +

+ {comment.expand?.author.username} + {$_(`n-${timeSince.unit}-ago`, { + values: { n: timeSince.value }, + })}

{#if mode == "edit"}