@@ -7,12 +7,13 @@ import {
77 mdiAlert ,
88 mdiAccount ,
99} from ' @mdi/js'
10- import { formatPhoneNumber , startsWithLetter } from ' ~/utils/filters '
10+ import type { EntitiesMessageThread } from ' ~~/shared/types/api '
1111
1212const threadsStore = useThreadsStore ()
1313const phonesStore = usePhonesStore ()
1414const appStore = useAppStore ()
1515const notificationsStore = useNotificationsStore ()
16+ const { formatPhoneNumber, startsWithLetter } = useFilters ()
1617
1718function threadDate(date : string ): string {
1819 return new Date (date ).toLocaleString (undefined , {
@@ -27,6 +28,21 @@ function onInstallApp() {
2728 message: ' Downloading the httpSMS Android App' ,
2829 })
2930}
31+
32+ function threadContactName(thread : EntitiesMessageThread ): string {
33+ return thread .contact_details ?.name ?.trim () ?? ' '
34+ }
35+
36+ function threadContactTitle(thread : EntitiesMessageThread ): string {
37+ return threadContactName (thread ) || formatPhoneNumber (thread .contact )
38+ }
39+
40+ function threadAvatarInitial(thread : EntitiesMessageThread ): string {
41+ const contactName = threadContactName (thread )
42+ if (contactName ) return contactName .substring (0 , 1 )
43+
44+ return startsWithLetter (thread .contact ) ? thread .contact .substring (0 , 1 ) : ' '
45+ }
3046 </script >
3147
3248<template >
@@ -104,16 +120,16 @@ function onInstallApp() {
104120 size =" 40"
105121 :badge =" thread.is_read ? false : { color: 'primary', dotSize: 12 }"
106122 >
107- <v-icon v-if =" !startsWithLetter (thread.contact )" color =" white" >{{
123+ <v-icon v-if =" !threadAvatarInitial (thread)" color =" white" >{{
108124 mdiAccount
109125 }}</v-icon >
110126 <span v-else class =" text-white text-headline-small" >{{
111- thread.contact.substring(0, 1 )
127+ threadAvatarInitial(thread )
112128 }}</span >
113129 </v-avatar >
114130 </template >
115131 <v-list-item-title :class =" { 'font-weight-bold': !thread.is_read }" >{{
116- formatPhoneNumber (thread.contact )
132+ threadContactTitle (thread)
117133 }}</v-list-item-title >
118134 <v-list-item-subtitle
119135 class =" text-truncate mt-1"
0 commit comments