2019-10-29 07:20:54 +00:00
|
|
|
<template>
|
2020-05-02 04:17:36 +00:00
|
|
|
<div class="user-message-wrap">
|
|
|
|
<div class="user-message">
|
|
|
|
<div class="message-wrap" :class="{ 'in-progress': isInProgress }">
|
2020-06-15 08:05:52 +00:00
|
|
|
<user-message-bubble
|
2020-05-02 04:17:36 +00:00
|
|
|
v-if="showTextBubble"
|
|
|
|
:message="message.content"
|
|
|
|
:status="message.status"
|
2020-06-15 08:05:52 +00:00
|
|
|
:widget-color="widgetColor"
|
2020-05-02 04:17:36 +00:00
|
|
|
/>
|
2020-06-15 08:05:52 +00:00
|
|
|
<div
|
|
|
|
v-if="hasAttachments"
|
|
|
|
class="chat-bubble has-attachment user"
|
|
|
|
:style="{ backgroundColor: widgetColor }"
|
|
|
|
>
|
2020-05-02 04:17:36 +00:00
|
|
|
<div v-for="attachment in message.attachments" :key="attachment.id">
|
|
|
|
<file-bubble
|
|
|
|
v-if="attachment.file_type !== 'image'"
|
|
|
|
:url="attachment.data_url"
|
|
|
|
:is-in-progress="isInProgress"
|
|
|
|
/>
|
|
|
|
<image-bubble
|
|
|
|
v-else
|
|
|
|
:url="attachment.data_url"
|
|
|
|
:thumb="attachment.thumb_url"
|
|
|
|
:readable-time="readableTime"
|
|
|
|
/>
|
|
|
|
</div>
|
2020-04-17 15:45:20 +00:00
|
|
|
</div>
|
2020-03-30 06:45:06 +00:00
|
|
|
</div>
|
2019-10-29 07:20:54 +00:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
2020-03-30 06:45:06 +00:00
|
|
|
import UserMessageBubble from 'widget/components/UserMessageBubble';
|
|
|
|
import ImageBubble from 'widget/components/ImageBubble';
|
2020-04-02 06:58:38 +00:00
|
|
|
import FileBubble from 'widget/components/FileBubble';
|
2020-03-30 06:45:06 +00:00
|
|
|
import timeMixin from 'dashboard/mixins/time';
|
2021-07-15 08:57:37 +00:00
|
|
|
import messageMixin from '../mixins/messageMixin';
|
2020-06-15 08:05:52 +00:00
|
|
|
import { mapGetters } from 'vuex';
|
2019-10-29 07:20:54 +00:00
|
|
|
|
|
|
|
export default {
|
|
|
|
name: 'UserMessage',
|
|
|
|
components: {
|
|
|
|
UserMessageBubble,
|
2020-03-30 06:45:06 +00:00
|
|
|
ImageBubble,
|
2020-04-02 06:58:38 +00:00
|
|
|
FileBubble,
|
2019-10-29 07:20:54 +00:00
|
|
|
},
|
2021-07-15 08:57:37 +00:00
|
|
|
mixins: [timeMixin, messageMixin],
|
2019-10-29 07:20:54 +00:00
|
|
|
props: {
|
2020-03-30 06:45:06 +00:00
|
|
|
message: {
|
|
|
|
type: Object,
|
|
|
|
default: () => {},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
computed: {
|
2020-06-15 08:05:52 +00:00
|
|
|
...mapGetters({
|
|
|
|
widgetColor: 'appConfig/getWidgetColor',
|
|
|
|
}),
|
|
|
|
|
2020-03-30 06:45:06 +00:00
|
|
|
isInProgress() {
|
|
|
|
const { status = '' } = this.message;
|
|
|
|
return status === 'in_progress';
|
|
|
|
},
|
|
|
|
showTextBubble() {
|
|
|
|
const { message } = this;
|
|
|
|
return !!message.content;
|
|
|
|
},
|
|
|
|
readableTime() {
|
|
|
|
const { created_at: createdAt = '' } = this.message;
|
|
|
|
return this.messageStamp(createdAt);
|
2019-11-29 12:12:35 +00:00
|
|
|
},
|
2019-10-29 07:20:54 +00:00
|
|
|
},
|
|
|
|
};
|
|
|
|
</script>
|