WIP display attachment type in the last message

This commit is contained in:
eugenijm 2020-05-14 18:18:40 +03:00
parent c9870a9d43
commit cf4d3ee1bf
3 changed files with 23 additions and 2 deletions

View file

@ -1,4 +1,5 @@
import { mapState } from 'vuex'
import fileType from 'src/services/file_type/file_type.service'
import ChatAvatar from '../chat_avatar/chat_avatar.vue'
import AvatarList from '../avatar_list/avatar_list.vue'
import Timeago from '../timeago/timeago.vue'
@ -18,7 +19,21 @@ const ChatListItem = {
computed: {
...mapState({
currentUser: state => state.users.currentUser
})
}),
attachmentInfo () {
if (this.chat.lastMessage.attachments.length === 0) { return }
let types = this.chat.lastMessage.attachments.map(file => fileType.fileType(file.mimetype))
if (types.includes('video')) {
return this.$t('file_type.video')
} else if (types.includes('audio')) {
return this.$t('file_type.audio')
} else if (types.includes('image')) {
return this.$t('file_type.image')
} else {
return this.$t('file_type.file')
}
}
},
methods: {
openChat (_e) {

View file

@ -29,7 +29,7 @@
<div class="chat-preview">
<span
class="content"
v-html="chat.lastMessage && chat.lastMessage.content"
v-html="chat.lastMessage && (attachmentInfo || chat.lastMessage.content)"
/>
<div
v-if="chat.unread > 0"

View file

@ -763,6 +763,12 @@
"more": "More",
"delete_confirm": "Do you really want to delete this message?"
},
"file_type": {
"audio": "Audio",
"video": "Video",
"image": "Image",
"file": "File"
},
"display_date": {
"today": "Today"
}