2020-07-07 18:34:44 +00:00
|
|
|
<template>
|
|
|
|
<div class="unread-wrap">
|
|
|
|
<div class="close-unread-wrap">
|
2022-01-12 10:55:27 +00:00
|
|
|
<button class="button small close-unread-button" @click="closeFullView">
|
|
|
|
<span class="flex items-center">
|
2021-11-18 09:48:51 +00:00
|
|
|
<fluent-icon class="mr-1" icon="dismiss" size="12" />
|
|
|
|
{{ $t('UNREAD_VIEW.CLOSE_MESSAGES_BUTTON') }}
|
2022-01-12 10:55:27 +00:00
|
|
|
</span>
|
2020-07-07 18:34:44 +00:00
|
|
|
</button>
|
|
|
|
</div>
|
|
|
|
<div class="unread-messages">
|
2021-05-17 16:08:59 +00:00
|
|
|
<unread-message
|
2022-01-12 10:55:27 +00:00
|
|
|
v-for="(message, index) in messages"
|
2020-07-07 18:34:44 +00:00
|
|
|
:key="message.id"
|
2021-06-15 14:39:42 +00:00
|
|
|
:message-type="message.messageType"
|
2020-07-07 18:34:44 +00:00
|
|
|
:message-id="message.id"
|
2021-05-17 16:08:59 +00:00
|
|
|
:show-sender="!index"
|
|
|
|
:sender="message.sender"
|
2021-01-06 12:26:29 +00:00
|
|
|
:message="getMessageContent(message)"
|
2021-06-15 14:39:42 +00:00
|
|
|
:campaign-id="message.campaignId"
|
2020-07-07 18:34:44 +00:00
|
|
|
/>
|
|
|
|
</div>
|
2021-05-17 16:08:59 +00:00
|
|
|
|
2021-08-14 03:10:29 +00:00
|
|
|
<div class="open-read-view-wrap">
|
2020-07-07 18:34:44 +00:00
|
|
|
<button
|
|
|
|
v-if="unreadMessageCount"
|
|
|
|
class="button clear-button"
|
2022-01-12 10:55:27 +00:00
|
|
|
@click="openConversationView"
|
2020-07-07 18:34:44 +00:00
|
|
|
>
|
2022-01-12 10:55:27 +00:00
|
|
|
<span class="flex items-center">
|
2021-11-18 09:48:51 +00:00
|
|
|
<fluent-icon class="mr-2" size="16" icon="arrow-right" />
|
|
|
|
{{ $t('UNREAD_VIEW.VIEW_MESSAGES_BUTTON') }}
|
2022-01-12 10:55:27 +00:00
|
|
|
</span>
|
2020-07-07 18:34:44 +00:00
|
|
|
</button>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
|
|
|
import { IFrameHelper } from 'widget/helpers/utils';
|
2021-02-15 18:44:13 +00:00
|
|
|
import { mapGetters } from 'vuex';
|
2021-11-18 09:48:51 +00:00
|
|
|
import configMixin from '../mixins/configMixin';
|
2022-01-12 10:55:27 +00:00
|
|
|
import { ON_UNREAD_MESSAGE_CLICK } from '../constants/widgetBusEvents';
|
2021-11-18 09:48:51 +00:00
|
|
|
import FluentIcon from 'shared/components/FluentIcon/Index.vue';
|
|
|
|
import UnreadMessage from 'widget/components/UnreadMessage.vue';
|
2020-07-07 18:34:44 +00:00
|
|
|
|
|
|
|
export default {
|
|
|
|
name: 'Unread',
|
|
|
|
components: {
|
2021-11-18 09:48:51 +00:00
|
|
|
FluentIcon,
|
2021-05-17 16:08:59 +00:00
|
|
|
UnreadMessage,
|
2020-07-07 18:34:44 +00:00
|
|
|
},
|
|
|
|
mixins: [configMixin],
|
|
|
|
props: {
|
2022-01-12 10:55:27 +00:00
|
|
|
messages: {
|
|
|
|
type: Array,
|
|
|
|
required: true,
|
2021-06-15 14:39:42 +00:00
|
|
|
},
|
2020-07-07 18:34:44 +00:00
|
|
|
},
|
|
|
|
computed: {
|
2022-01-12 10:55:27 +00:00
|
|
|
...mapGetters({ unreadMessageCount: 'conversation/getUnreadMessageCount' }),
|
2021-05-17 16:08:59 +00:00
|
|
|
sender() {
|
2022-01-12 10:55:27 +00:00
|
|
|
const [firstMessage] = this.messages;
|
2021-05-17 16:08:59 +00:00
|
|
|
return firstMessage.sender || {};
|
|
|
|
},
|
2020-07-07 18:34:44 +00:00
|
|
|
},
|
|
|
|
methods: {
|
2022-01-12 10:55:27 +00:00
|
|
|
openConversationView() {
|
|
|
|
bus.$emit(ON_UNREAD_MESSAGE_CLICK);
|
2020-07-07 18:34:44 +00:00
|
|
|
},
|
|
|
|
closeFullView() {
|
|
|
|
if (IFrameHelper.isIFrame()) {
|
2022-01-12 10:55:27 +00:00
|
|
|
IFrameHelper.sendMessage({ event: 'toggleBubble' });
|
2020-07-07 18:34:44 +00:00
|
|
|
}
|
|
|
|
},
|
2021-01-06 12:26:29 +00:00
|
|
|
getMessageContent(message) {
|
|
|
|
const { attachments, content } = message;
|
|
|
|
const hasAttachments = attachments && attachments.length;
|
|
|
|
|
|
|
|
if (content) return content;
|
|
|
|
|
|
|
|
if (hasAttachments) return `📑`;
|
|
|
|
|
|
|
|
return '';
|
|
|
|
},
|
2020-07-07 18:34:44 +00:00
|
|
|
},
|
|
|
|
};
|
|
|
|
</script>
|
|
|
|
<style lang="scss" scoped>
|
2020-10-18 18:02:22 +00:00
|
|
|
@import '~widget/assets/scss/variables';
|
|
|
|
|
2020-07-07 18:34:44 +00:00
|
|
|
.unread-wrap {
|
|
|
|
width: 100%;
|
2021-08-07 06:26:15 +00:00
|
|
|
height: auto;
|
|
|
|
max-height: 100vh;
|
2020-07-07 18:34:44 +00:00
|
|
|
background: transparent;
|
|
|
|
display: flex;
|
|
|
|
flex-direction: column;
|
|
|
|
flex-wrap: nowrap;
|
|
|
|
justify-content: flex-end;
|
|
|
|
overflow: hidden;
|
|
|
|
|
|
|
|
.unread-messages {
|
|
|
|
padding-bottom: $space-small;
|
|
|
|
}
|
|
|
|
|
|
|
|
.clear-button {
|
|
|
|
background: transparent;
|
|
|
|
color: $color-woot;
|
|
|
|
border: 0;
|
|
|
|
font-weight: $font-weight-bold;
|
|
|
|
font-size: $font-size-medium;
|
2022-08-08 15:32:29 +00:00
|
|
|
transition: all 0.3s var(--ease-in-cubic);
|
2020-07-07 18:34:44 +00:00
|
|
|
margin-left: $space-smaller;
|
2022-10-14 03:43:11 +00:00
|
|
|
padding: 0 $space-one 0 0;
|
2020-07-07 18:34:44 +00:00
|
|
|
|
|
|
|
&:hover {
|
|
|
|
transform: translateX($space-smaller);
|
|
|
|
color: $color-primary-dark;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
.close-unread-button {
|
|
|
|
background: $color-background;
|
2021-08-07 06:26:40 +00:00
|
|
|
color: $color-light-gray;
|
2020-07-07 18:34:44 +00:00
|
|
|
border: 0;
|
2021-08-07 06:26:40 +00:00
|
|
|
font-weight: $font-weight-medium;
|
|
|
|
font-size: $font-size-mini;
|
2022-08-08 15:32:29 +00:00
|
|
|
transition: all 0.3s var(--ease-in-cubic);
|
2020-07-07 18:34:44 +00:00
|
|
|
margin-bottom: $space-slab;
|
|
|
|
border-radius: $space-normal;
|
|
|
|
|
|
|
|
&:hover {
|
|
|
|
color: $color-body;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</style>
|