From cf4d3ee1bf70b679d82d9454d2e2a714473317a1 Mon Sep 17 00:00:00 2001 From: eugenijm Date: Thu, 14 May 2020 18:18:40 +0300 Subject: [PATCH] WIP display attachment type in the last message --- src/components/chat_list_item/chat_list_item.js | 17 ++++++++++++++++- .../chat_list_item/chat_list_item.vue | 2 +- src/i18n/en.json | 6 ++++++ 3 files changed, 23 insertions(+), 2 deletions(-) diff --git a/src/components/chat_list_item/chat_list_item.js b/src/components/chat_list_item/chat_list_item.js index 72399782..d31ba359 100644 --- a/src/components/chat_list_item/chat_list_item.js +++ b/src/components/chat_list_item/chat_list_item.js @@ -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) { diff --git a/src/components/chat_list_item/chat_list_item.vue b/src/components/chat_list_item/chat_list_item.vue index 07931759..94482706 100644 --- a/src/components/chat_list_item/chat_list_item.vue +++ b/src/components/chat_list_item/chat_list_item.vue @@ -29,7 +29,7 @@