2019-08-14 09:48:44 +00:00
|
|
|
<template>
|
2022-02-25 05:33:16 +00:00
|
|
|
<li
|
|
|
|
v-if="hasAttachments || data.content || isEmailContentType"
|
|
|
|
:class="alignBubble"
|
|
|
|
>
|
2019-08-14 09:48:44 +00:00
|
|
|
<div :class="wrapClass">
|
2021-12-20 18:37:33 +00:00
|
|
|
<div v-tooltip.top-start="messageToolTip" :class="bubbleClass">
|
2021-07-28 09:13:44 +00:00
|
|
|
<bubble-mail-head
|
|
|
|
:email-attributes="contentAttributes.email"
|
2021-10-11 07:30:48 +00:00
|
|
|
:cc="emailHeadAttributes.cc"
|
|
|
|
:bcc="emailHeadAttributes.bcc"
|
2021-07-28 09:13:44 +00:00
|
|
|
:is-incoming="isIncoming"
|
|
|
|
/>
|
2019-11-17 07:39:10 +00:00
|
|
|
<bubble-text
|
|
|
|
v-if="data.content"
|
|
|
|
:message="message"
|
2020-08-01 15:26:47 +00:00
|
|
|
:is-email="isEmailContentType"
|
2019-11-17 07:39:10 +00:00
|
|
|
:readable-time="readableTime"
|
2021-09-14 06:25:48 +00:00
|
|
|
:display-quoted-button="displayQuotedButton"
|
2019-11-17 07:39:10 +00:00
|
|
|
/>
|
2020-12-25 07:45:01 +00:00
|
|
|
<span
|
|
|
|
v-if="isPending && hasAttachments"
|
|
|
|
class="chat-bubble has-attachment agent"
|
|
|
|
>
|
|
|
|
{{ $t('CONVERSATION.UPLOADING_ATTACHMENTS') }}
|
|
|
|
</span>
|
2021-01-06 12:26:29 +00:00
|
|
|
<div v-if="!isPending && hasAttachments">
|
|
|
|
<div v-for="attachment in data.attachments" :key="attachment.id">
|
2020-04-17 15:45:20 +00:00
|
|
|
<bubble-image
|
2021-12-20 18:20:37 +00:00
|
|
|
v-if="attachment.file_type === 'image' && !hasImageError"
|
2020-04-17 15:45:20 +00:00
|
|
|
:url="attachment.data_url"
|
|
|
|
:readable-time="readableTime"
|
2021-12-20 18:20:37 +00:00
|
|
|
@error="onImageLoadError"
|
2020-04-17 15:45:20 +00:00
|
|
|
/>
|
2021-02-11 11:56:14 +00:00
|
|
|
<audio v-else-if="attachment.file_type === 'audio'" controls>
|
|
|
|
<source :src="attachment.data_url" />
|
|
|
|
</audio>
|
2021-10-25 14:16:37 +00:00
|
|
|
<bubble-video
|
|
|
|
v-else-if="attachment.file_type === 'video'"
|
|
|
|
:url="attachment.data_url"
|
|
|
|
:readable-time="readableTime"
|
|
|
|
/>
|
2022-11-08 05:36:47 +00:00
|
|
|
<bubble-location
|
|
|
|
v-else-if="attachment.file_type === 'location'"
|
|
|
|
:latitude="attachment.coordinates_lat"
|
|
|
|
:longitude="attachment.coordinates_long"
|
|
|
|
:name="attachment.fallback_title"
|
|
|
|
/>
|
2020-04-17 15:45:20 +00:00
|
|
|
<bubble-file
|
2021-02-11 11:56:14 +00:00
|
|
|
v-else
|
2020-04-17 15:45:20 +00:00
|
|
|
:url="attachment.data_url"
|
|
|
|
:readable-time="readableTime"
|
|
|
|
/>
|
2021-01-06 12:26:29 +00:00
|
|
|
</div>
|
|
|
|
</div>
|
2020-08-01 15:26:47 +00:00
|
|
|
<bubble-actions
|
2020-08-11 04:27:42 +00:00
|
|
|
:id="data.id"
|
|
|
|
:sender="data.sender"
|
2022-03-10 14:57:30 +00:00
|
|
|
:story-sender="storySender"
|
|
|
|
:story-id="storyId"
|
2020-08-11 04:27:42 +00:00
|
|
|
:is-a-tweet="isATweet"
|
2022-03-10 14:57:30 +00:00
|
|
|
:has-instagram-story="hasInstagramStory"
|
2020-08-01 15:26:47 +00:00
|
|
|
:is-email="isEmailContentType"
|
|
|
|
:is-private="data.private"
|
2020-08-11 04:27:42 +00:00
|
|
|
:message-type="data.message_type"
|
|
|
|
:readable-time="readableTime"
|
|
|
|
:source-id="data.source_id"
|
2021-08-02 10:37:30 +00:00
|
|
|
:inbox-id="data.inbox_id"
|
2022-04-20 10:33:12 +00:00
|
|
|
:message-read="showReadTicks"
|
2019-12-16 12:53:14 +00:00
|
|
|
/>
|
2020-12-25 07:45:01 +00:00
|
|
|
</div>
|
|
|
|
<spinner v-if="isPending" size="tiny" />
|
2022-02-01 11:04:54 +00:00
|
|
|
<div
|
|
|
|
v-if="showAvatar"
|
2022-06-24 17:42:53 +00:00
|
|
|
v-tooltip.left="tooltipForSender"
|
2021-01-05 04:36:40 +00:00
|
|
|
class="sender--info"
|
|
|
|
>
|
2020-08-11 04:27:42 +00:00
|
|
|
<woot-thumbnail
|
|
|
|
:src="sender.thumbnail"
|
2022-02-03 06:44:34 +00:00
|
|
|
:username="senderNameForAvatar"
|
2020-08-11 04:27:42 +00:00
|
|
|
size="16px"
|
|
|
|
/>
|
2022-02-01 11:04:54 +00:00
|
|
|
<a
|
|
|
|
v-if="isATweet && isIncoming"
|
|
|
|
class="sender--available-name"
|
|
|
|
:href="twitterProfileLink"
|
|
|
|
target="_blank"
|
|
|
|
rel="noopener noreferrer nofollow"
|
|
|
|
>
|
2020-10-13 18:46:35 +00:00
|
|
|
{{ sender.name }}
|
2022-02-01 11:04:54 +00:00
|
|
|
</a>
|
|
|
|
</div>
|
2021-12-20 18:37:33 +00:00
|
|
|
<div v-if="isFailed" class="message-failed--alert">
|
|
|
|
<woot-button
|
|
|
|
v-tooltip.top-end="$t('CONVERSATION.TRY_AGAIN')"
|
|
|
|
size="tiny"
|
|
|
|
color-scheme="alert"
|
|
|
|
variant="clear"
|
|
|
|
icon="arrow-clockwise"
|
|
|
|
@click="retrySendMessage"
|
|
|
|
/>
|
|
|
|
</div>
|
2019-08-14 09:48:44 +00:00
|
|
|
</div>
|
2021-12-20 18:37:33 +00:00
|
|
|
<div v-if="shouldShowContextMenu" class="context-menu-wrap">
|
2021-07-13 06:30:29 +00:00
|
|
|
<context-menu
|
2021-07-15 15:36:54 +00:00
|
|
|
v-if="isBubble && !isMessageDeleted"
|
2021-07-13 06:30:29 +00:00
|
|
|
:is-open="showContextMenu"
|
|
|
|
:show-copy="hasText"
|
2022-10-06 05:00:15 +00:00
|
|
|
:show-canned-response-option="isOutgoing"
|
2021-07-13 06:30:29 +00:00
|
|
|
:menu-position="contextMenuPosition"
|
2022-10-06 05:00:15 +00:00
|
|
|
:message-content="data.content"
|
2021-07-13 06:30:29 +00:00
|
|
|
@toggle="handleContextMenuClick"
|
|
|
|
@delete="handleDelete"
|
|
|
|
/>
|
|
|
|
</div>
|
2019-08-14 09:48:44 +00:00
|
|
|
</li>
|
|
|
|
</template>
|
|
|
|
<script>
|
2019-11-23 18:59:55 +00:00
|
|
|
import messageFormatterMixin from 'shared/mixins/messageFormatterMixin';
|
2019-08-14 09:48:44 +00:00
|
|
|
import timeMixin from '../../../mixins/time';
|
2021-08-07 06:26:15 +00:00
|
|
|
|
2021-07-28 09:13:44 +00:00
|
|
|
import BubbleMailHead from './bubble/MailHead';
|
2019-08-14 09:48:44 +00:00
|
|
|
import BubbleText from './bubble/Text';
|
|
|
|
import BubbleImage from './bubble/Image';
|
2020-04-02 06:58:38 +00:00
|
|
|
import BubbleFile from './bubble/File';
|
2021-10-25 14:16:37 +00:00
|
|
|
import BubbleVideo from './bubble/Video.vue';
|
2021-08-07 06:26:15 +00:00
|
|
|
import BubbleActions from './bubble/Actions';
|
2022-11-08 05:36:47 +00:00
|
|
|
import BubbleLocation from './bubble/Location';
|
2021-08-07 06:26:15 +00:00
|
|
|
|
2020-12-25 07:45:01 +00:00
|
|
|
import Spinner from 'shared/components/Spinner';
|
2021-06-29 14:36:40 +00:00
|
|
|
import ContextMenu from 'dashboard/modules/conversations/components/MessageContextMenu';
|
|
|
|
|
|
|
|
import alertMixin from 'shared/mixins/alertMixin';
|
2020-08-01 15:26:47 +00:00
|
|
|
import contentTypeMixin from 'shared/mixins/contentTypeMixin';
|
2020-12-25 07:45:01 +00:00
|
|
|
import { MESSAGE_TYPE, MESSAGE_STATUS } from 'shared/constants/messages';
|
2021-02-09 09:49:47 +00:00
|
|
|
import { generateBotMessageContent } from './helpers/botMessageContentHelper';
|
2021-06-26 06:20:40 +00:00
|
|
|
|
2019-08-14 09:48:44 +00:00
|
|
|
export default {
|
|
|
|
components: {
|
2020-08-01 15:26:47 +00:00
|
|
|
BubbleActions,
|
2019-08-14 09:48:44 +00:00
|
|
|
BubbleText,
|
|
|
|
BubbleImage,
|
2020-04-02 06:58:38 +00:00
|
|
|
BubbleFile,
|
2021-10-25 14:16:37 +00:00
|
|
|
BubbleVideo,
|
2021-07-28 09:13:44 +00:00
|
|
|
BubbleMailHead,
|
2022-11-08 05:36:47 +00:00
|
|
|
BubbleLocation,
|
2021-06-29 14:36:40 +00:00
|
|
|
ContextMenu,
|
2020-12-25 07:45:01 +00:00
|
|
|
Spinner,
|
2019-08-14 09:48:44 +00:00
|
|
|
},
|
2021-06-29 14:36:40 +00:00
|
|
|
mixins: [alertMixin, timeMixin, messageFormatterMixin, contentTypeMixin],
|
2019-11-17 07:39:10 +00:00
|
|
|
props: {
|
|
|
|
data: {
|
|
|
|
type: Object,
|
|
|
|
required: true,
|
|
|
|
},
|
2020-08-11 04:27:42 +00:00
|
|
|
isATweet: {
|
|
|
|
type: Boolean,
|
|
|
|
default: false,
|
|
|
|
},
|
2022-03-10 14:57:30 +00:00
|
|
|
hasInstagramStory: {
|
|
|
|
type: Boolean,
|
|
|
|
default: false,
|
|
|
|
},
|
2022-04-20 10:33:12 +00:00
|
|
|
hasUserReadMessage: {
|
|
|
|
type: Boolean,
|
|
|
|
default: false,
|
|
|
|
},
|
|
|
|
isWebWidgetInbox: {
|
|
|
|
type: Boolean,
|
|
|
|
default: false,
|
|
|
|
},
|
2019-11-17 07:39:10 +00:00
|
|
|
},
|
2021-06-29 14:36:40 +00:00
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
showContextMenu: false,
|
2021-12-20 18:20:37 +00:00
|
|
|
hasImageError: false,
|
2021-06-29 14:36:40 +00:00
|
|
|
};
|
|
|
|
},
|
2019-08-14 09:48:44 +00:00
|
|
|
computed: {
|
2022-08-01 05:23:50 +00:00
|
|
|
emailMessageContent() {
|
2021-09-14 06:25:48 +00:00
|
|
|
const {
|
|
|
|
html_content: { full: fullHTMLContent } = {},
|
|
|
|
text_content: { full: fullTextContent } = {},
|
|
|
|
} = this.contentAttributes.email || {};
|
|
|
|
return fullHTMLContent || fullTextContent || '';
|
|
|
|
},
|
|
|
|
displayQuotedButton() {
|
|
|
|
if (!this.isIncoming) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2022-08-01 05:23:50 +00:00
|
|
|
if (this.emailMessageContent.includes('<blockquote')) {
|
2021-09-14 06:25:48 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
},
|
2019-08-14 09:48:44 +00:00
|
|
|
message() {
|
2022-09-21 00:15:32 +00:00
|
|
|
if (this.contentType === 'input_csat') {
|
|
|
|
return this.$t('CONVERSATION.CSAT_REPLY_MESSAGE');
|
|
|
|
}
|
|
|
|
|
2022-08-01 05:23:50 +00:00
|
|
|
// If the message is an email, emailMessageContent would be present
|
|
|
|
// In that case, we would use letter package to render the email
|
|
|
|
if (this.emailMessageContent && this.isIncoming) {
|
|
|
|
return this.emailMessageContent;
|
|
|
|
}
|
|
|
|
|
2021-02-09 09:49:47 +00:00
|
|
|
const botMessageContent = generateBotMessageContent(
|
|
|
|
this.contentType,
|
|
|
|
this.contentAttributes,
|
2021-06-25 08:07:51 +00:00
|
|
|
{
|
|
|
|
noResponseText: this.$t('CONVERSATION.NO_RESPONSE'),
|
|
|
|
csat: {
|
|
|
|
ratingTitle: this.$t('CONVERSATION.RATING_TITLE'),
|
|
|
|
feedbackTitle: this.$t('CONVERSATION.FEEDBACK_TITLE'),
|
|
|
|
},
|
|
|
|
}
|
2021-02-09 09:49:47 +00:00
|
|
|
);
|
2021-03-27 07:59:04 +00:00
|
|
|
return (
|
2022-03-31 14:52:52 +00:00
|
|
|
this.formatMessage(
|
|
|
|
this.data.content,
|
|
|
|
this.isATweet,
|
|
|
|
this.data.private
|
|
|
|
) + botMessageContent
|
2021-03-27 07:59:04 +00:00
|
|
|
);
|
2021-02-09 09:49:47 +00:00
|
|
|
},
|
|
|
|
contentAttributes() {
|
|
|
|
return this.data.content_attributes || {};
|
2020-08-11 04:27:42 +00:00
|
|
|
},
|
|
|
|
sender() {
|
|
|
|
return this.data.sender || {};
|
2019-08-14 09:48:44 +00:00
|
|
|
},
|
2022-03-10 14:57:30 +00:00
|
|
|
storySender() {
|
2022-03-10 16:36:59 +00:00
|
|
|
return this.contentAttributes.story_sender || null;
|
2022-03-10 14:57:30 +00:00
|
|
|
},
|
|
|
|
storyId() {
|
2022-03-10 16:36:59 +00:00
|
|
|
return this.contentAttributes.story_id || null;
|
2022-03-10 14:57:30 +00:00
|
|
|
},
|
2020-08-01 15:26:47 +00:00
|
|
|
contentType() {
|
|
|
|
const {
|
|
|
|
data: { content_type: contentType },
|
|
|
|
} = this;
|
|
|
|
return contentType;
|
|
|
|
},
|
2021-01-05 04:36:40 +00:00
|
|
|
twitterProfileLink() {
|
|
|
|
const additionalAttributes = this.sender.additional_attributes || {};
|
|
|
|
const { screen_name: screenName } = additionalAttributes;
|
|
|
|
return `https://twitter.com/${screenName}`;
|
|
|
|
},
|
2019-08-14 09:48:44 +00:00
|
|
|
alignBubble() {
|
2021-04-13 17:28:54 +00:00
|
|
|
const { message_type: messageType } = this.data;
|
2021-06-29 14:36:40 +00:00
|
|
|
const isCentered = messageType === MESSAGE_TYPE.ACTIVITY;
|
2021-07-09 05:23:28 +00:00
|
|
|
const isLeftAligned = messageType === MESSAGE_TYPE.INCOMING;
|
|
|
|
const isRightAligned =
|
|
|
|
messageType === MESSAGE_TYPE.OUTGOING ||
|
|
|
|
messageType === MESSAGE_TYPE.TEMPLATE;
|
|
|
|
|
2021-06-29 14:36:40 +00:00
|
|
|
return {
|
|
|
|
center: isCentered,
|
2021-07-09 05:23:28 +00:00
|
|
|
left: isLeftAligned,
|
|
|
|
right: isRightAligned,
|
2021-06-29 14:36:40 +00:00
|
|
|
'has-context-menu': this.showContextMenu,
|
2021-07-09 05:23:28 +00:00
|
|
|
'has-tweet-menu': this.isATweet,
|
2021-06-29 14:36:40 +00:00
|
|
|
};
|
2019-08-14 09:48:44 +00:00
|
|
|
},
|
|
|
|
readableTime() {
|
2021-06-07 19:41:06 +00:00
|
|
|
return this.messageStamp(
|
|
|
|
this.contentAttributes.external_created_at || this.data.created_at,
|
|
|
|
'LLL d, h:mm a'
|
|
|
|
);
|
2019-08-14 09:48:44 +00:00
|
|
|
},
|
|
|
|
isBubble() {
|
2020-01-09 07:36:40 +00:00
|
|
|
return [0, 1, 3].includes(this.data.message_type);
|
2019-08-14 09:48:44 +00:00
|
|
|
},
|
2020-08-11 04:27:42 +00:00
|
|
|
isIncoming() {
|
|
|
|
return this.data.message_type === MESSAGE_TYPE.INCOMING;
|
|
|
|
},
|
2022-02-01 11:04:54 +00:00
|
|
|
isOutgoing() {
|
|
|
|
return this.data.message_type === MESSAGE_TYPE.OUTGOING;
|
|
|
|
},
|
2022-04-20 10:33:12 +00:00
|
|
|
showReadTicks() {
|
|
|
|
return (
|
|
|
|
(this.isOutgoing || this.isTemplate) &&
|
|
|
|
this.hasUserReadMessage &&
|
|
|
|
this.isWebWidgetInbox &&
|
|
|
|
!this.data.private
|
|
|
|
);
|
|
|
|
},
|
2022-02-03 06:44:34 +00:00
|
|
|
isTemplate() {
|
|
|
|
return this.data.message_type === MESSAGE_TYPE.TEMPLATE;
|
|
|
|
},
|
2021-10-11 07:30:48 +00:00
|
|
|
emailHeadAttributes() {
|
|
|
|
return {
|
|
|
|
email: this.contentAttributes.email,
|
|
|
|
cc: this.contentAttributes.cc_emails,
|
2021-12-01 05:03:18 +00:00
|
|
|
bcc: this.contentAttributes.bcc_emails,
|
|
|
|
};
|
2021-10-11 07:30:48 +00:00
|
|
|
},
|
2020-04-17 15:45:20 +00:00
|
|
|
hasAttachments() {
|
|
|
|
return !!(this.data.attachments && this.data.attachments.length > 0);
|
|
|
|
},
|
2021-07-15 15:36:54 +00:00
|
|
|
isMessageDeleted() {
|
|
|
|
return this.contentAttributes.deleted;
|
|
|
|
},
|
2021-01-06 12:26:29 +00:00
|
|
|
hasText() {
|
|
|
|
return !!this.data.content;
|
|
|
|
},
|
2022-02-01 11:04:54 +00:00
|
|
|
tooltipForSender() {
|
2022-02-03 06:44:34 +00:00
|
|
|
const name = this.senderNameForAvatar;
|
|
|
|
const { message_type: messageType } = this.data;
|
|
|
|
const showTooltip =
|
|
|
|
messageType === MESSAGE_TYPE.OUTGOING ||
|
|
|
|
messageType === MESSAGE_TYPE.TEMPLATE;
|
|
|
|
return showTooltip
|
2022-02-01 11:04:54 +00:00
|
|
|
? {
|
|
|
|
content: `${this.$t('CONVERSATION.SENT_BY')} ${name}`,
|
|
|
|
}
|
|
|
|
: false;
|
|
|
|
},
|
2021-12-20 18:37:33 +00:00
|
|
|
messageToolTip() {
|
2021-07-15 15:36:54 +00:00
|
|
|
if (this.isMessageDeleted) {
|
|
|
|
return false;
|
|
|
|
}
|
2021-12-20 18:37:33 +00:00
|
|
|
if (this.isFailed) {
|
|
|
|
return this.$t(`CONVERSATION.SEND_FAILED`);
|
|
|
|
}
|
2022-02-01 11:04:54 +00:00
|
|
|
return false;
|
2019-08-14 09:48:44 +00:00
|
|
|
},
|
|
|
|
wrapClass() {
|
|
|
|
return {
|
|
|
|
wrap: this.isBubble,
|
|
|
|
'activity-wrap': !this.isBubble,
|
2020-12-25 07:45:01 +00:00
|
|
|
'is-pending': this.isPending,
|
2021-12-20 18:37:33 +00:00
|
|
|
'is-failed': this.isFailed,
|
2022-08-01 05:23:50 +00:00
|
|
|
'is-email': this.isEmailContentType,
|
2019-08-14 09:48:44 +00:00
|
|
|
};
|
|
|
|
},
|
2020-03-22 10:24:36 +00:00
|
|
|
bubbleClass() {
|
|
|
|
return {
|
|
|
|
bubble: this.isBubble,
|
2020-08-01 15:26:47 +00:00
|
|
|
'is-private': this.data.private,
|
2021-10-25 14:16:37 +00:00
|
|
|
'is-image': this.hasMediaAttachment('image'),
|
|
|
|
'is-video': this.hasMediaAttachment('video'),
|
2021-01-06 12:26:29 +00:00
|
|
|
'is-text': this.hasText,
|
2021-06-04 16:24:06 +00:00
|
|
|
'is-from-bot': this.isSentByBot,
|
2021-12-20 18:37:33 +00:00
|
|
|
'is-failed': this.isFailed,
|
2022-08-01 05:23:50 +00:00
|
|
|
'is-email': this.isEmailContentType,
|
2020-03-22 10:24:36 +00:00
|
|
|
};
|
|
|
|
},
|
2020-12-25 07:45:01 +00:00
|
|
|
isPending() {
|
|
|
|
return this.data.status === MESSAGE_STATUS.PROGRESS;
|
|
|
|
},
|
2021-12-20 18:37:33 +00:00
|
|
|
isFailed() {
|
|
|
|
return this.data.status === MESSAGE_STATUS.FAILED;
|
|
|
|
},
|
2021-06-04 16:24:06 +00:00
|
|
|
isSentByBot() {
|
2021-12-20 18:37:33 +00:00
|
|
|
if (this.isPending || this.isFailed) return false;
|
2021-06-07 19:41:06 +00:00
|
|
|
return !this.sender.type || this.sender.type === 'agent_bot';
|
2021-06-04 16:24:06 +00:00
|
|
|
},
|
2021-06-29 14:36:40 +00:00
|
|
|
contextMenuPosition() {
|
|
|
|
const { message_type: messageType } = this.data;
|
|
|
|
return messageType ? 'right' : 'left';
|
|
|
|
},
|
2021-12-20 18:37:33 +00:00
|
|
|
shouldShowContextMenu() {
|
|
|
|
return !(this.isFailed || this.isPending);
|
|
|
|
},
|
|
|
|
errorMessage() {
|
|
|
|
const { meta } = this.data;
|
|
|
|
return meta ? meta.error : '';
|
|
|
|
},
|
2022-02-01 11:04:54 +00:00
|
|
|
showAvatar() {
|
2022-02-03 06:44:34 +00:00
|
|
|
if (this.isOutgoing || this.isTemplate) {
|
|
|
|
return true;
|
2022-02-01 11:04:54 +00:00
|
|
|
}
|
|
|
|
return this.isATweet && this.isIncoming && this.sender;
|
|
|
|
},
|
2022-02-03 06:44:34 +00:00
|
|
|
senderNameForAvatar() {
|
|
|
|
if (this.isOutgoing || this.isTemplate) {
|
|
|
|
const { name = this.$t('CONVERSATION.BOT') } = this.sender || {};
|
|
|
|
return name;
|
|
|
|
}
|
|
|
|
return '';
|
|
|
|
},
|
2021-06-29 14:36:40 +00:00
|
|
|
},
|
2021-12-20 18:20:37 +00:00
|
|
|
watch: {
|
|
|
|
data() {
|
|
|
|
this.hasImageError = false;
|
|
|
|
},
|
|
|
|
},
|
|
|
|
mounted() {
|
|
|
|
this.hasImageError = false;
|
|
|
|
},
|
2021-06-29 14:36:40 +00:00
|
|
|
methods: {
|
2021-10-25 14:16:37 +00:00
|
|
|
hasMediaAttachment(type) {
|
|
|
|
if (this.hasAttachments && this.data.attachments.length > 0) {
|
|
|
|
const { attachments = [{}] } = this.data;
|
|
|
|
const { file_type: fileType } = attachments[0];
|
2021-12-20 18:20:37 +00:00
|
|
|
return fileType === type && !this.hasImageError;
|
2021-10-25 14:16:37 +00:00
|
|
|
}
|
|
|
|
return false;
|
|
|
|
},
|
2021-06-29 14:36:40 +00:00
|
|
|
handleContextMenuClick() {
|
|
|
|
this.showContextMenu = !this.showContextMenu;
|
|
|
|
},
|
|
|
|
async handleDelete() {
|
|
|
|
const { conversation_id: conversationId, id: messageId } = this.data;
|
|
|
|
try {
|
|
|
|
await this.$store.dispatch('deleteMessage', {
|
|
|
|
conversationId,
|
|
|
|
messageId,
|
|
|
|
});
|
|
|
|
this.showAlert(this.$t('CONVERSATION.SUCCESS_DELETE_MESSAGE'));
|
|
|
|
this.showContextMenu = false;
|
|
|
|
} catch (error) {
|
|
|
|
this.showAlert(this.$t('CONVERSATION.FAIL_DELETE_MESSSAGE'));
|
|
|
|
}
|
|
|
|
},
|
2021-12-20 18:37:33 +00:00
|
|
|
async retrySendMessage() {
|
|
|
|
await this.$store.dispatch('sendMessageWithData', this.data);
|
|
|
|
},
|
2021-12-20 18:20:37 +00:00
|
|
|
onImageLoadError() {
|
|
|
|
this.hasImageError = true;
|
|
|
|
},
|
2019-08-14 09:48:44 +00:00
|
|
|
},
|
|
|
|
};
|
|
|
|
</script>
|
2020-08-01 15:26:47 +00:00
|
|
|
<style lang="scss">
|
2020-12-25 07:45:01 +00:00
|
|
|
.wrap {
|
2021-01-06 12:26:29 +00:00
|
|
|
> .bubble {
|
2022-10-16 23:48:32 +00:00
|
|
|
min-width: 128px;
|
|
|
|
|
2021-10-25 14:16:37 +00:00
|
|
|
&.is-image,
|
|
|
|
&.is-video {
|
2021-01-06 12:26:29 +00:00
|
|
|
padding: 0;
|
|
|
|
overflow: hidden;
|
2020-12-25 07:45:01 +00:00
|
|
|
|
2021-10-25 14:16:37 +00:00
|
|
|
.image,
|
|
|
|
.video {
|
2021-01-06 12:26:29 +00:00
|
|
|
max-width: 32rem;
|
|
|
|
padding: var(--space-micro);
|
|
|
|
|
2021-10-25 14:16:37 +00:00
|
|
|
> img,
|
|
|
|
> video {
|
2021-01-06 12:26:29 +00:00
|
|
|
border-radius: var(--border-radius-medium);
|
|
|
|
}
|
2021-10-25 14:16:37 +00:00
|
|
|
> video {
|
|
|
|
height: 100%;
|
|
|
|
object-fit: cover;
|
|
|
|
width: 100%;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
.video {
|
|
|
|
height: 18rem;
|
2021-01-06 12:26:29 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
&.is-image.is-text > .message-text__wrap {
|
2020-12-25 07:45:01 +00:00
|
|
|
max-width: 32rem;
|
2021-01-06 12:26:29 +00:00
|
|
|
padding: var(--space-small) var(--space-normal);
|
2020-12-25 07:45:01 +00:00
|
|
|
}
|
2021-02-17 07:20:26 +00:00
|
|
|
|
2021-02-15 18:23:52 +00:00
|
|
|
&.is-private .file.message-text__wrap {
|
2021-12-01 05:03:18 +00:00
|
|
|
.file--icon {
|
2021-02-15 18:23:52 +00:00
|
|
|
color: var(--w-400);
|
|
|
|
}
|
|
|
|
.text-block-title {
|
|
|
|
color: #3c4858;
|
|
|
|
}
|
|
|
|
.download.button {
|
|
|
|
color: var(--w-400);
|
|
|
|
}
|
|
|
|
}
|
2021-02-17 07:20:26 +00:00
|
|
|
|
2021-02-15 12:54:58 +00:00
|
|
|
&.is-private.is-text > .message-text__wrap .link {
|
|
|
|
color: var(--w-700);
|
|
|
|
}
|
2021-02-17 07:20:26 +00:00
|
|
|
&.is-private.is-text > .message-text__wrap .prosemirror-mention-node {
|
|
|
|
font-weight: var(--font-weight-black);
|
|
|
|
background: none;
|
|
|
|
border-radius: var(--border-radius-small);
|
|
|
|
padding: 0;
|
|
|
|
color: var(--color-body);
|
|
|
|
text-decoration: underline;
|
|
|
|
}
|
2021-06-04 16:24:06 +00:00
|
|
|
|
|
|
|
&.is-from-bot {
|
|
|
|
background: var(--v-400);
|
|
|
|
.message-text--metadata .time {
|
|
|
|
color: var(--v-50);
|
|
|
|
}
|
2022-01-13 18:54:52 +00:00
|
|
|
&.is-private .message-text--metadata .time {
|
|
|
|
color: var(--s-400);
|
|
|
|
}
|
2021-06-04 16:24:06 +00:00
|
|
|
}
|
2021-12-20 18:37:33 +00:00
|
|
|
|
|
|
|
&.is-failed {
|
|
|
|
background: var(--r-200);
|
|
|
|
|
|
|
|
.message-text--metadata .time {
|
|
|
|
color: var(--r-50);
|
|
|
|
}
|
|
|
|
}
|
2020-12-25 07:45:01 +00:00
|
|
|
}
|
2021-01-06 12:26:29 +00:00
|
|
|
|
2020-12-25 07:45:01 +00:00
|
|
|
&.is-pending {
|
|
|
|
position: relative;
|
|
|
|
opacity: 0.8;
|
|
|
|
|
|
|
|
.spinner {
|
|
|
|
position: absolute;
|
|
|
|
bottom: var(--space-smaller);
|
|
|
|
right: var(--space-smaller);
|
|
|
|
}
|
2021-01-06 12:26:29 +00:00
|
|
|
|
|
|
|
> .is-image.is-text.bubble > .message-text__wrap {
|
|
|
|
padding: 0;
|
|
|
|
}
|
2020-03-22 10:24:36 +00:00
|
|
|
}
|
|
|
|
}
|
2020-08-11 04:27:42 +00:00
|
|
|
|
2022-08-01 05:23:50 +00:00
|
|
|
.wrap.is-email {
|
|
|
|
--bubble-max-width: 84% !important;
|
|
|
|
}
|
|
|
|
|
2020-08-11 04:27:42 +00:00
|
|
|
.sender--info {
|
|
|
|
align-items: center;
|
2021-01-05 04:36:40 +00:00
|
|
|
color: var(--b-700);
|
|
|
|
display: inline-flex;
|
2020-08-11 04:27:42 +00:00
|
|
|
padding: var(--space-smaller) 0;
|
|
|
|
|
|
|
|
.sender--available-name {
|
|
|
|
font-size: var(--font-size-mini);
|
|
|
|
margin-left: var(--space-smaller);
|
|
|
|
}
|
|
|
|
}
|
2021-06-29 14:36:40 +00:00
|
|
|
|
2021-12-20 18:37:33 +00:00
|
|
|
.message-failed--alert {
|
|
|
|
color: var(--r-900);
|
|
|
|
flex-grow: 1;
|
|
|
|
text-align: right;
|
|
|
|
margin-top: var(--space-smaller) var(--space-smaller) 0 0;
|
|
|
|
}
|
|
|
|
|
2021-06-29 14:36:40 +00:00
|
|
|
.button--delete-message {
|
|
|
|
visibility: hidden;
|
|
|
|
}
|
|
|
|
|
2021-07-09 05:23:28 +00:00
|
|
|
li.left,
|
|
|
|
li.right {
|
2021-06-29 14:36:40 +00:00
|
|
|
display: flex;
|
|
|
|
align-items: flex-end;
|
2021-07-09 05:23:28 +00:00
|
|
|
|
|
|
|
&:hover .button--delete-message {
|
|
|
|
visibility: visible;
|
|
|
|
}
|
2021-06-29 14:36:40 +00:00
|
|
|
}
|
|
|
|
|
2021-07-09 05:23:28 +00:00
|
|
|
li.left.has-tweet-menu .context-menu {
|
|
|
|
margin-bottom: var(--space-medium);
|
|
|
|
}
|
|
|
|
|
2021-07-13 06:30:29 +00:00
|
|
|
li.right .context-menu-wrap {
|
2021-07-09 05:23:28 +00:00
|
|
|
margin-left: auto;
|
2021-06-29 14:36:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
li.right {
|
2021-07-09 05:23:28 +00:00
|
|
|
flex-direction: row-reverse;
|
|
|
|
justify-content: flex-end;
|
2021-12-20 18:37:33 +00:00
|
|
|
|
|
|
|
.wrap.is-pending {
|
|
|
|
margin-left: auto;
|
|
|
|
}
|
|
|
|
|
|
|
|
.wrap.is-failed {
|
|
|
|
display: flex;
|
|
|
|
flex-direction: row-reverse;
|
|
|
|
align-items: flex-end;
|
|
|
|
margin-left: auto;
|
|
|
|
}
|
2021-06-29 14:36:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
.has-context-menu {
|
|
|
|
background: var(--color-background);
|
|
|
|
.button--delete-message {
|
|
|
|
visibility: visible;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
.context-menu {
|
|
|
|
position: relative;
|
|
|
|
}
|
2020-03-22 10:24:36 +00:00
|
|
|
</style>
|