diff --git a/web/app/components/MessageThread.vue b/web/app/components/MessageThread.vue index 93c77324d..2a699408a 100644 --- a/web/app/components/MessageThread.vue +++ b/web/app/components/MessageThread.vue @@ -8,6 +8,10 @@ import { mdiAccount, } from '@mdi/js' import type { EntitiesMessageThread } from '~~/shared/types/api' +import { + isUrlNotificationToken, + formatWhatsappText, +} from '~/utils/whatsapp-format' const threadsStore = useThreadsStore() const phonesStore = usePhonesStore() @@ -45,6 +49,19 @@ function onInstallApp() { }) } +function isWhatsappFormatted(thread: EntitiesMessageThread): boolean { + const phone = phonesStore.phones.find((x) => x.phone_number === thread.owner) + return isUrlNotificationToken(phone?.fcm_token) +} + +function threadPreviewHtml(thread: EntitiesMessageThread): string { + // Links are unwrapped because the preview sits inside a router link. + return formatWhatsappText(thread.last_message_content ?? '').replace( + /]*>(.*?)<\/a>/g, + '$1', + ) +} + function threadContactName(thread: EntitiesMessageThread): string { return thread.contact_details?.name?.trim() ?? '' } @@ -160,7 +177,13 @@ function threadAvatarInitial(thread: EntitiesMessageThread): string { }" style="max-width: 250px" > - {{ thread.last_message_content }} + + + +