2019-08-14 09:48:44 +00:00
|
|
|
<template>
|
2019-08-25 14:29:28 +00:00
|
|
|
<div
|
|
|
|
class="conversation"
|
2021-03-09 14:22:14 +00:00
|
|
|
:class="{
|
|
|
|
active: isActiveChat,
|
|
|
|
'unread-chat': hasUnread,
|
|
|
|
'has-inbox-name': showInboxName,
|
|
|
|
}"
|
2019-08-25 14:29:28 +00:00
|
|
|
@click="cardClick(chat)"
|
|
|
|
>
|
2021-09-29 10:53:39 +00:00
|
|
|
<thumbnail
|
2020-01-13 05:47:03 +00:00
|
|
|
v-if="!hideThumbnail"
|
2020-06-02 17:29:02 +00:00
|
|
|
:src="currentContact.thumbnail"
|
2021-10-06 14:04:34 +00:00
|
|
|
:badge="inboxBadge"
|
2019-08-25 14:29:28 +00:00
|
|
|
class="columns"
|
2020-06-02 17:29:02 +00:00
|
|
|
:username="currentContact.name"
|
2020-07-04 06:12:47 +00:00
|
|
|
:status="currentContact.availability_status"
|
2019-10-29 18:06:21 +00:00
|
|
|
size="40px"
|
2019-08-25 14:29:28 +00:00
|
|
|
/>
|
2019-08-14 09:48:44 +00:00
|
|
|
<div class="conversation--details columns">
|
2021-09-29 10:53:39 +00:00
|
|
|
<div class="conversation--metadata">
|
2021-09-29 14:03:51 +00:00
|
|
|
<inbox-name v-if="showInboxName" :inbox="inbox" />
|
2021-09-29 10:53:39 +00:00
|
|
|
<span
|
2021-10-06 14:04:34 +00:00
|
|
|
v-if="showAssignee && assignee.name"
|
2021-09-29 10:53:39 +00:00
|
|
|
class="label assignee-label text-truncate"
|
|
|
|
>
|
2021-12-01 05:03:18 +00:00
|
|
|
<fluent-icon icon="person" size="12" />
|
2021-09-29 10:53:39 +00:00
|
|
|
{{ assignee.name }}
|
|
|
|
</span>
|
|
|
|
</div>
|
2019-08-25 14:29:28 +00:00
|
|
|
<h4 class="conversation--user">
|
2020-06-02 17:29:02 +00:00
|
|
|
{{ currentContact.name }}
|
2019-08-25 14:29:28 +00:00
|
|
|
</h4>
|
2020-06-14 13:00:36 +00:00
|
|
|
<p v-if="lastMessageInChat" class="conversation--message">
|
2021-12-01 05:03:18 +00:00
|
|
|
<fluent-icon
|
|
|
|
v-if="isMessagePrivate"
|
|
|
|
size="16"
|
|
|
|
class="message--attachment-icon last-message-icon"
|
|
|
|
icon="lock-closed"
|
|
|
|
/>
|
|
|
|
<fluent-icon
|
|
|
|
v-else-if="messageByAgent"
|
|
|
|
size="16"
|
|
|
|
class="message--attachment-icon last-message-icon"
|
|
|
|
icon="arrow-reply"
|
|
|
|
/>
|
|
|
|
<fluent-icon
|
2021-08-03 06:43:24 +00:00
|
|
|
v-else-if="isMessageAnActivity"
|
2021-12-01 05:03:18 +00:00
|
|
|
size="16"
|
|
|
|
class="message--attachment-icon last-message-icon"
|
|
|
|
icon="info"
|
2021-08-03 06:43:24 +00:00
|
|
|
/>
|
2020-06-14 13:00:36 +00:00
|
|
|
<span v-if="lastMessageInChat.content">
|
2021-01-15 09:10:50 +00:00
|
|
|
{{ parsedLastMessage }}
|
2020-06-14 13:00:36 +00:00
|
|
|
</span>
|
2021-04-27 17:51:04 +00:00
|
|
|
<span v-else-if="lastMessageInChat.attachments">
|
2021-12-01 05:03:18 +00:00
|
|
|
<fluent-icon
|
|
|
|
size="16"
|
|
|
|
class="message--attachment-icon"
|
|
|
|
:icon="attachmentIcon"
|
|
|
|
/>
|
|
|
|
{{ this.$t(`${attachmentMessageContent}`) }}
|
2020-06-14 13:00:36 +00:00
|
|
|
</span>
|
2021-04-27 17:51:04 +00:00
|
|
|
<span v-else>
|
|
|
|
{{ $t('CHAT_LIST.NO_CONTENT') }}
|
|
|
|
</span>
|
2020-06-14 13:00:36 +00:00
|
|
|
</p>
|
2021-01-31 07:35:07 +00:00
|
|
|
<p v-else class="conversation--message">
|
2021-12-01 05:03:18 +00:00
|
|
|
<fluent-icon size="16" class="message--attachment-icon" icon="info" />
|
2021-01-31 07:35:07 +00:00
|
|
|
<span>
|
|
|
|
{{ this.$t(`CHAT_LIST.NO_MESSAGES`) }}
|
|
|
|
</span>
|
|
|
|
</p>
|
2019-08-14 09:48:44 +00:00
|
|
|
<div class="conversation--meta">
|
2019-08-25 14:29:28 +00:00
|
|
|
<span class="timestamp">
|
2020-06-14 13:00:36 +00:00
|
|
|
{{ dynamicTime(chat.timestamp) }}
|
2019-08-25 14:29:28 +00:00
|
|
|
</span>
|
2020-12-10 18:00:38 +00:00
|
|
|
<span class="unread">{{ unreadCount > 9 ? '9+' : unreadCount }}</span>
|
2019-08-14 09:48:44 +00:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
<script>
|
|
|
|
import { mapGetters } from 'vuex';
|
2020-07-03 17:55:33 +00:00
|
|
|
import { MESSAGE_TYPE } from 'widget/helpers/constants';
|
2021-01-15 09:10:50 +00:00
|
|
|
import messageFormatterMixin from 'shared/mixins/messageFormatterMixin';
|
2019-08-14 09:48:44 +00:00
|
|
|
import Thumbnail from '../Thumbnail';
|
|
|
|
import conversationMixin from '../../../mixins/conversations';
|
|
|
|
import timeMixin from '../../../mixins/time';
|
|
|
|
import router from '../../../routes';
|
2020-02-22 08:54:51 +00:00
|
|
|
import { frontendURL, conversationUrl } from '../../../helper/URLHelper';
|
2021-09-29 14:03:51 +00:00
|
|
|
import InboxName from '../InboxName';
|
2021-09-29 07:26:45 +00:00
|
|
|
import inboxMixin from 'shared/mixins/inboxMixin';
|
2019-08-14 09:48:44 +00:00
|
|
|
|
2021-12-01 05:03:18 +00:00
|
|
|
const ATTACHMENT_ICONS = {
|
|
|
|
image: 'image',
|
|
|
|
audio: 'headphones-sound-wave',
|
|
|
|
video: 'video',
|
|
|
|
file: 'document',
|
|
|
|
location: 'location',
|
|
|
|
fallback: 'link',
|
|
|
|
};
|
|
|
|
|
2019-08-14 09:48:44 +00:00
|
|
|
export default {
|
|
|
|
components: {
|
2021-09-29 14:03:51 +00:00
|
|
|
InboxName,
|
2019-08-14 09:48:44 +00:00
|
|
|
Thumbnail,
|
|
|
|
},
|
|
|
|
|
2021-09-29 07:26:45 +00:00
|
|
|
mixins: [inboxMixin, timeMixin, conversationMixin, messageFormatterMixin],
|
2019-08-25 14:29:28 +00:00
|
|
|
props: {
|
2020-06-25 15:34:03 +00:00
|
|
|
activeLabel: {
|
|
|
|
type: String,
|
|
|
|
default: '',
|
|
|
|
},
|
2019-08-25 14:29:28 +00:00
|
|
|
chat: {
|
|
|
|
type: Object,
|
|
|
|
default: () => {},
|
|
|
|
},
|
2020-01-13 05:47:03 +00:00
|
|
|
hideInboxName: {
|
|
|
|
type: Boolean,
|
|
|
|
default: false,
|
|
|
|
},
|
|
|
|
hideThumbnail: {
|
|
|
|
type: Boolean,
|
|
|
|
default: false,
|
|
|
|
},
|
2021-03-16 14:14:50 +00:00
|
|
|
teamId: {
|
|
|
|
type: [String, Number],
|
|
|
|
default: 0,
|
|
|
|
},
|
2021-09-29 10:53:39 +00:00
|
|
|
showAssignee: {
|
|
|
|
type: Boolean,
|
|
|
|
default: false,
|
|
|
|
},
|
2021-12-09 05:50:14 +00:00
|
|
|
conversationType: {
|
|
|
|
type: String,
|
|
|
|
default: '',
|
|
|
|
},
|
2019-08-14 09:48:44 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
computed: {
|
|
|
|
...mapGetters({
|
|
|
|
currentChat: 'getSelectedChat',
|
2019-12-28 16:26:42 +00:00
|
|
|
inboxesList: 'inboxes/getInboxes',
|
2019-08-14 09:48:44 +00:00
|
|
|
activeInbox: 'getSelectedInbox',
|
2020-03-09 17:57:10 +00:00
|
|
|
currentUser: 'getCurrentUser',
|
2020-05-26 18:06:42 +00:00
|
|
|
accountId: 'getCurrentAccountId',
|
2019-08-14 09:48:44 +00:00
|
|
|
}),
|
|
|
|
|
2020-07-04 14:16:17 +00:00
|
|
|
chatMetadata() {
|
2021-09-29 10:53:39 +00:00
|
|
|
return this.chat.meta || {};
|
|
|
|
},
|
|
|
|
|
|
|
|
assignee() {
|
|
|
|
return this.chatMetadata.assignee || {};
|
2020-07-04 14:16:17 +00:00
|
|
|
},
|
|
|
|
|
2020-06-02 17:29:02 +00:00
|
|
|
currentContact() {
|
|
|
|
return this.$store.getters['contacts/getContact'](
|
2020-07-04 14:16:17 +00:00
|
|
|
this.chatMetadata.sender.id
|
2020-06-02 17:29:02 +00:00
|
|
|
);
|
|
|
|
},
|
|
|
|
|
2021-12-01 05:03:18 +00:00
|
|
|
lastMessageFileType() {
|
2020-06-14 13:00:36 +00:00
|
|
|
const lastMessage = this.lastMessageInChat;
|
|
|
|
const [{ file_type: fileType } = {}] = lastMessage.attachments;
|
2021-12-01 05:03:18 +00:00
|
|
|
return fileType;
|
|
|
|
},
|
|
|
|
|
|
|
|
attachmentIcon() {
|
|
|
|
return ATTACHMENT_ICONS[this.lastMessageFileType];
|
|
|
|
},
|
|
|
|
|
|
|
|
attachmentMessageContent() {
|
|
|
|
return `CHAT_LIST.ATTACHMENTS.${this.lastMessageFileType}.CONTENT`;
|
2020-06-14 13:00:36 +00:00
|
|
|
},
|
|
|
|
|
2019-08-14 09:48:44 +00:00
|
|
|
isActiveChat() {
|
|
|
|
return this.currentChat.id === this.chat.id;
|
|
|
|
},
|
|
|
|
|
2020-12-10 18:00:38 +00:00
|
|
|
unreadCount() {
|
2019-08-14 09:48:44 +00:00
|
|
|
return this.unreadMessagesCount(this.chat);
|
|
|
|
},
|
|
|
|
|
|
|
|
hasUnread() {
|
2020-12-10 18:00:38 +00:00
|
|
|
return this.unreadCount > 0;
|
2019-08-14 09:48:44 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
isInboxNameVisible() {
|
|
|
|
return !this.activeInbox;
|
|
|
|
},
|
2020-06-02 17:29:02 +00:00
|
|
|
|
|
|
|
lastMessageInChat() {
|
|
|
|
return this.lastMessage(this.chat);
|
|
|
|
},
|
2020-07-03 17:55:33 +00:00
|
|
|
|
|
|
|
messageByAgent() {
|
|
|
|
const lastMessage = this.lastMessageInChat;
|
|
|
|
const { message_type: messageType } = lastMessage;
|
|
|
|
return messageType === MESSAGE_TYPE.OUTGOING;
|
|
|
|
},
|
2021-01-15 09:10:50 +00:00
|
|
|
|
2021-08-03 06:43:24 +00:00
|
|
|
isMessageAnActivity() {
|
|
|
|
const lastMessage = this.lastMessageInChat;
|
|
|
|
const { message_type: messageType } = lastMessage;
|
|
|
|
return messageType === MESSAGE_TYPE.ACTIVITY;
|
|
|
|
},
|
|
|
|
|
|
|
|
isMessagePrivate() {
|
|
|
|
const lastMessage = this.lastMessageInChat;
|
|
|
|
const { private: isPrivate } = lastMessage;
|
|
|
|
return isPrivate;
|
|
|
|
},
|
|
|
|
|
2021-01-15 09:10:50 +00:00
|
|
|
parsedLastMessage() {
|
2021-03-27 07:59:04 +00:00
|
|
|
const { content_attributes: contentAttributes } = this.lastMessageInChat;
|
|
|
|
const { email: { subject } = {} } = contentAttributes || {};
|
|
|
|
return this.getPlainText(subject || this.lastMessageInChat.content);
|
2021-01-15 09:10:50 +00:00
|
|
|
},
|
2021-03-09 14:22:14 +00:00
|
|
|
|
2021-09-29 07:26:45 +00:00
|
|
|
inbox() {
|
2021-03-09 14:22:14 +00:00
|
|
|
const { inbox_id: inboxId } = this.chat;
|
|
|
|
const stateInbox = this.$store.getters['inboxes/getInbox'](inboxId);
|
|
|
|
return stateInbox;
|
|
|
|
},
|
|
|
|
|
|
|
|
showInboxName() {
|
2021-03-29 05:39:06 +00:00
|
|
|
return (
|
|
|
|
!this.hideInboxName &&
|
|
|
|
this.isInboxNameVisible &&
|
|
|
|
this.inboxesList.length > 1
|
|
|
|
);
|
2021-03-09 14:22:14 +00:00
|
|
|
},
|
|
|
|
inboxName() {
|
2021-09-29 07:26:45 +00:00
|
|
|
const stateInbox = this.inbox;
|
2021-03-09 14:22:14 +00:00
|
|
|
return stateInbox.name || '';
|
|
|
|
},
|
2019-08-14 09:48:44 +00:00
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
cardClick(chat) {
|
2020-02-22 08:54:51 +00:00
|
|
|
const { activeInbox } = this;
|
2020-06-25 15:34:03 +00:00
|
|
|
const path = conversationUrl({
|
|
|
|
accountId: this.accountId,
|
|
|
|
activeInbox,
|
|
|
|
id: chat.id,
|
|
|
|
label: this.activeLabel,
|
2021-03-16 14:14:50 +00:00
|
|
|
teamId: this.teamId,
|
2021-12-09 05:50:14 +00:00
|
|
|
conversationType: this.conversationType,
|
2020-06-25 15:34:03 +00:00
|
|
|
});
|
2020-02-22 08:54:51 +00:00
|
|
|
router.push({ path: frontendURL(path) });
|
2019-08-14 09:48:44 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
};
|
|
|
|
</script>
|
2021-03-09 14:22:14 +00:00
|
|
|
<style lang="scss" scoped>
|
|
|
|
.conversation {
|
|
|
|
align-items: center;
|
2021-04-06 14:52:38 +00:00
|
|
|
|
|
|
|
&:hover {
|
|
|
|
background: var(--color-background-light);
|
|
|
|
}
|
2021-03-09 14:22:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
.has-inbox-name {
|
|
|
|
&::v-deep .user-thumbnail-box {
|
2021-03-10 05:03:45 +00:00
|
|
|
margin-top: var(--space-normal);
|
2021-03-09 14:22:14 +00:00
|
|
|
align-items: flex-start;
|
|
|
|
}
|
2021-03-10 05:03:45 +00:00
|
|
|
.conversation--meta {
|
|
|
|
margin-top: var(--space-normal);
|
|
|
|
}
|
2021-03-09 14:22:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
.conversation--details {
|
2021-03-10 05:03:45 +00:00
|
|
|
.conversation--user {
|
|
|
|
padding-top: var(--space-micro);
|
2021-03-15 13:08:37 +00:00
|
|
|
text-overflow: ellipsis;
|
|
|
|
overflow: hidden;
|
|
|
|
white-space: nowrap;
|
|
|
|
width: 60%;
|
2021-03-10 05:03:45 +00:00
|
|
|
}
|
2021-03-09 14:22:14 +00:00
|
|
|
}
|
2021-08-03 06:43:24 +00:00
|
|
|
|
|
|
|
.last-message-icon {
|
|
|
|
color: var(--s-600);
|
|
|
|
}
|
2021-09-29 10:53:39 +00:00
|
|
|
|
|
|
|
.conversation--metadata {
|
|
|
|
display: flex;
|
|
|
|
justify-content: space-between;
|
|
|
|
padding-right: var(--space-normal);
|
|
|
|
|
2021-09-29 14:03:51 +00:00
|
|
|
.label {
|
|
|
|
background: none;
|
|
|
|
color: var(--s-500);
|
|
|
|
font-size: var(--font-size-mini);
|
2021-12-01 05:03:18 +00:00
|
|
|
font-weight: var(--font-weight-medium);
|
|
|
|
line-height: var(--space-slab);
|
|
|
|
padding: var(--space-micro) 0 var(--space-micro) 0;
|
2021-09-29 14:03:51 +00:00
|
|
|
}
|
|
|
|
|
2021-09-29 10:53:39 +00:00
|
|
|
.assignee-label {
|
2021-12-01 05:03:18 +00:00
|
|
|
display: inline-flex;
|
2021-09-29 10:53:39 +00:00
|
|
|
max-width: 50%;
|
|
|
|
}
|
|
|
|
}
|
2021-12-01 05:03:18 +00:00
|
|
|
|
|
|
|
.message--attachment-icon {
|
|
|
|
margin-top: var(--space-minus-micro);
|
|
|
|
vertical-align: middle;
|
|
|
|
}
|
2021-03-09 14:22:14 +00:00
|
|
|
</style>
|