fix: Update the logic to show read status for web (#6107)
This commit is contained in:
parent
3c6bd2c8fd
commit
26ada8b342
5 changed files with 75 additions and 76 deletions
|
@ -15,7 +15,6 @@
|
||||||
v-if="data.content"
|
v-if="data.content"
|
||||||
:message="message"
|
:message="message"
|
||||||
:is-email="isEmailContentType"
|
:is-email="isEmailContentType"
|
||||||
:readable-time="readableTime"
|
|
||||||
:display-quoted-button="displayQuotedButton"
|
:display-quoted-button="displayQuotedButton"
|
||||||
/>
|
/>
|
||||||
<span
|
<span
|
||||||
|
@ -29,7 +28,6 @@
|
||||||
<bubble-image
|
<bubble-image
|
||||||
v-if="attachment.file_type === 'image' && !hasImageError"
|
v-if="attachment.file_type === 'image' && !hasImageError"
|
||||||
:url="attachment.data_url"
|
:url="attachment.data_url"
|
||||||
:readable-time="readableTime"
|
|
||||||
@error="onImageLoadError"
|
@error="onImageLoadError"
|
||||||
/>
|
/>
|
||||||
<audio v-else-if="attachment.file_type === 'audio'" controls>
|
<audio v-else-if="attachment.file_type === 'audio'" controls>
|
||||||
|
@ -38,7 +36,6 @@
|
||||||
<bubble-video
|
<bubble-video
|
||||||
v-else-if="attachment.file_type === 'video'"
|
v-else-if="attachment.file_type === 'video'"
|
||||||
:url="attachment.data_url"
|
:url="attachment.data_url"
|
||||||
:readable-time="readableTime"
|
|
||||||
/>
|
/>
|
||||||
<bubble-location
|
<bubble-location
|
||||||
v-else-if="attachment.file_type === 'location'"
|
v-else-if="attachment.file_type === 'location'"
|
||||||
|
@ -46,11 +43,7 @@
|
||||||
:longitude="attachment.coordinates_long"
|
:longitude="attachment.coordinates_long"
|
||||||
:name="attachment.fallback_title"
|
:name="attachment.fallback_title"
|
||||||
/>
|
/>
|
||||||
<bubble-file
|
<bubble-file v-else :url="attachment.data_url" />
|
||||||
v-else
|
|
||||||
:url="attachment.data_url"
|
|
||||||
:readable-time="readableTime"
|
|
||||||
/>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<bubble-actions
|
<bubble-actions
|
||||||
|
@ -65,10 +58,9 @@
|
||||||
:is-private="data.private"
|
:is-private="data.private"
|
||||||
:message-type="data.message_type"
|
:message-type="data.message_type"
|
||||||
:message-status="status"
|
:message-status="status"
|
||||||
:readable-time="readableTime"
|
|
||||||
:source-id="data.source_id"
|
:source-id="data.source_id"
|
||||||
:inbox-id="data.inbox_id"
|
:inbox-id="data.inbox_id"
|
||||||
:message-read="showReadTicks"
|
:created-at="createdAt"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<spinner v-if="isPending" size="tiny" />
|
<spinner v-if="isPending" size="tiny" />
|
||||||
|
@ -119,8 +111,6 @@
|
||||||
</template>
|
</template>
|
||||||
<script>
|
<script>
|
||||||
import messageFormatterMixin from 'shared/mixins/messageFormatterMixin';
|
import messageFormatterMixin from 'shared/mixins/messageFormatterMixin';
|
||||||
import timeMixin from '../../../mixins/time';
|
|
||||||
|
|
||||||
import BubbleMailHead from './bubble/MailHead';
|
import BubbleMailHead from './bubble/MailHead';
|
||||||
import BubbleText from './bubble/Text';
|
import BubbleText from './bubble/Text';
|
||||||
import BubbleImage from './bubble/Image';
|
import BubbleImage from './bubble/Image';
|
||||||
|
@ -149,7 +139,7 @@ export default {
|
||||||
ContextMenu,
|
ContextMenu,
|
||||||
Spinner,
|
Spinner,
|
||||||
},
|
},
|
||||||
mixins: [alertMixin, timeMixin, messageFormatterMixin, contentTypeMixin],
|
mixins: [alertMixin, messageFormatterMixin, contentTypeMixin],
|
||||||
props: {
|
props: {
|
||||||
data: {
|
data: {
|
||||||
type: Object,
|
type: Object,
|
||||||
|
@ -167,10 +157,6 @@ export default {
|
||||||
type: Boolean,
|
type: Boolean,
|
||||||
default: false,
|
default: false,
|
||||||
},
|
},
|
||||||
hasUserReadMessage: {
|
|
||||||
type: Boolean,
|
|
||||||
default: false,
|
|
||||||
},
|
|
||||||
isWebWidgetInbox: {
|
isWebWidgetInbox: {
|
||||||
type: Boolean,
|
type: Boolean,
|
||||||
default: false,
|
default: false,
|
||||||
|
@ -273,11 +259,8 @@ export default {
|
||||||
'has-tweet-menu': this.isATweet,
|
'has-tweet-menu': this.isATweet,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
readableTime() {
|
createdAt() {
|
||||||
return this.messageStamp(
|
return this.contentAttributes.external_created_at || this.data.created_at;
|
||||||
this.contentAttributes.external_created_at || this.data.created_at,
|
|
||||||
'LLL d, h:mm a'
|
|
||||||
);
|
|
||||||
},
|
},
|
||||||
isBubble() {
|
isBubble() {
|
||||||
return [0, 1, 3].includes(this.data.message_type);
|
return [0, 1, 3].includes(this.data.message_type);
|
||||||
|
@ -288,14 +271,6 @@ export default {
|
||||||
isOutgoing() {
|
isOutgoing() {
|
||||||
return this.data.message_type === MESSAGE_TYPE.OUTGOING;
|
return this.data.message_type === MESSAGE_TYPE.OUTGOING;
|
||||||
},
|
},
|
||||||
showReadTicks() {
|
|
||||||
return (
|
|
||||||
(this.isOutgoing || this.isTemplate) &&
|
|
||||||
this.hasUserReadMessage &&
|
|
||||||
this.isWebWidgetInbox &&
|
|
||||||
!this.data.private
|
|
||||||
);
|
|
||||||
},
|
|
||||||
isTemplate() {
|
isTemplate() {
|
||||||
return this.data.message_type === MESSAGE_TYPE.TEMPLATE;
|
return this.data.message_type === MESSAGE_TYPE.TEMPLATE;
|
||||||
},
|
},
|
||||||
|
|
|
@ -40,9 +40,6 @@
|
||||||
:is-a-tweet="isATweet"
|
:is-a-tweet="isATweet"
|
||||||
:is-a-whatsapp-channel="isAWhatsAppChannel"
|
:is-a-whatsapp-channel="isAWhatsAppChannel"
|
||||||
:has-instagram-story="hasInstagramStory"
|
:has-instagram-story="hasInstagramStory"
|
||||||
:has-user-read-message="
|
|
||||||
hasUserReadMessage(message.created_at, getLastSeenAt)
|
|
||||||
"
|
|
||||||
:is-web-widget-inbox="isAWebWidgetInbox"
|
:is-web-widget-inbox="isAWebWidgetInbox"
|
||||||
/>
|
/>
|
||||||
<li v-show="unreadMessageCount != 0" class="unread--toast">
|
<li v-show="unreadMessageCount != 0" class="unread--toast">
|
||||||
|
@ -63,9 +60,6 @@
|
||||||
:is-a-tweet="isATweet"
|
:is-a-tweet="isATweet"
|
||||||
:is-a-whatsapp-channel="isAWhatsAppChannel"
|
:is-a-whatsapp-channel="isAWhatsAppChannel"
|
||||||
:has-instagram-story="hasInstagramStory"
|
:has-instagram-story="hasInstagramStory"
|
||||||
:has-user-read-message="
|
|
||||||
hasUserReadMessage(message.created_at, getLastSeenAt)
|
|
||||||
"
|
|
||||||
:is-web-widget-inbox="isAWebWidgetInbox"
|
:is-web-widget-inbox="isAWebWidgetInbox"
|
||||||
/>
|
/>
|
||||||
</ul>
|
</ul>
|
||||||
|
|
|
@ -1,8 +1,14 @@
|
||||||
<template>
|
<template>
|
||||||
<div class="message-text--metadata">
|
<div class="message-text--metadata">
|
||||||
<span class="time" :class="{ delivered: messageRead }">{{
|
<span
|
||||||
readableTime
|
class="time"
|
||||||
}}</span>
|
:class="{
|
||||||
|
'has-status-icon':
|
||||||
|
showSentIndicator || showDeliveredIndicator || showReadIndicator,
|
||||||
|
}"
|
||||||
|
>
|
||||||
|
{{ readableTime }}
|
||||||
|
</span>
|
||||||
<span v-if="showReadIndicator" class="read-indicator-wrap">
|
<span v-if="showReadIndicator" class="read-indicator-wrap">
|
||||||
<fluent-icon
|
<fluent-icon
|
||||||
v-tooltip.top-start="$t('CHAT_LIST.MESSAGE_READ')"
|
v-tooltip.top-start="$t('CHAT_LIST.MESSAGE_READ')"
|
||||||
|
@ -11,7 +17,7 @@
|
||||||
size="14"
|
size="14"
|
||||||
/>
|
/>
|
||||||
</span>
|
</span>
|
||||||
<span v-if="showDeliveredIndicator" class="read-indicator-wrap">
|
<span v-else-if="showDeliveredIndicator" class="read-indicator-wrap">
|
||||||
<fluent-icon
|
<fluent-icon
|
||||||
v-tooltip.top-start="$t('CHAT_LIST.DELIVERED')"
|
v-tooltip.top-start="$t('CHAT_LIST.DELIVERED')"
|
||||||
icon="checkmark-double"
|
icon="checkmark-double"
|
||||||
|
@ -19,7 +25,7 @@
|
||||||
size="14"
|
size="14"
|
||||||
/>
|
/>
|
||||||
</span>
|
</span>
|
||||||
<span v-if="showSentIndicator" class="read-indicator-wrap">
|
<span v-else-if="showSentIndicator" class="read-indicator-wrap">
|
||||||
<fluent-icon
|
<fluent-icon
|
||||||
v-tooltip.top-start="$t('CHAT_LIST.SENT')"
|
v-tooltip.top-start="$t('CHAT_LIST.SENT')"
|
||||||
icon="checkmark"
|
icon="checkmark"
|
||||||
|
@ -74,17 +80,19 @@
|
||||||
import { MESSAGE_TYPE, MESSAGE_STATUS } from 'shared/constants/messages';
|
import { MESSAGE_TYPE, MESSAGE_STATUS } from 'shared/constants/messages';
|
||||||
import { BUS_EVENTS } from 'shared/constants/busEvents';
|
import { BUS_EVENTS } from 'shared/constants/busEvents';
|
||||||
import inboxMixin from 'shared/mixins/inboxMixin';
|
import inboxMixin from 'shared/mixins/inboxMixin';
|
||||||
|
import { mapGetters } from 'vuex';
|
||||||
|
import timeMixin from '../../../../mixins/time';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
mixins: [inboxMixin],
|
mixins: [inboxMixin, timeMixin],
|
||||||
props: {
|
props: {
|
||||||
sender: {
|
sender: {
|
||||||
type: Object,
|
type: Object,
|
||||||
default: () => ({}),
|
default: () => ({}),
|
||||||
},
|
},
|
||||||
readableTime: {
|
createdAt: {
|
||||||
type: String,
|
type: Number,
|
||||||
default: '',
|
default: 0,
|
||||||
},
|
},
|
||||||
storySender: {
|
storySender: {
|
||||||
type: String,
|
type: String,
|
||||||
|
@ -130,12 +138,9 @@ export default {
|
||||||
type: [String, Number],
|
type: [String, Number],
|
||||||
default: 0,
|
default: 0,
|
||||||
},
|
},
|
||||||
messageRead: {
|
|
||||||
type: Boolean,
|
|
||||||
default: false,
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
|
...mapGetters({ currentChat: 'getSelectedChat' }),
|
||||||
inbox() {
|
inbox() {
|
||||||
return this.$store.getters['inboxes/getInbox'](this.inboxId);
|
return this.$store.getters['inboxes/getInbox'](this.inboxId);
|
||||||
},
|
},
|
||||||
|
@ -145,6 +150,9 @@ export default {
|
||||||
isOutgoing() {
|
isOutgoing() {
|
||||||
return MESSAGE_TYPE.OUTGOING === this.messageType;
|
return MESSAGE_TYPE.OUTGOING === this.messageType;
|
||||||
},
|
},
|
||||||
|
isTemplate() {
|
||||||
|
return MESSAGE_TYPE.TEMPLATE === this.messageType;
|
||||||
|
},
|
||||||
isDelivered() {
|
isDelivered() {
|
||||||
return MESSAGE_STATUS.DELIVERED === this.messageStatus;
|
return MESSAGE_STATUS.DELIVERED === this.messageStatus;
|
||||||
},
|
},
|
||||||
|
@ -154,6 +162,9 @@ export default {
|
||||||
isSent() {
|
isSent() {
|
||||||
return MESSAGE_STATUS.SENT === this.messageStatus;
|
return MESSAGE_STATUS.SENT === this.messageStatus;
|
||||||
},
|
},
|
||||||
|
readableTime() {
|
||||||
|
return this.messageStamp(this.createdAt, 'LLL d, h:mm a');
|
||||||
|
},
|
||||||
screenName() {
|
screenName() {
|
||||||
const { additional_attributes: additionalAttributes = {} } =
|
const { additional_attributes: additionalAttributes = {} } =
|
||||||
this.sender || {};
|
this.sender || {};
|
||||||
|
@ -174,28 +185,52 @@ export default {
|
||||||
const { storySender, storyId } = this;
|
const { storySender, storyId } = this;
|
||||||
return `https://www.instagram.com/stories/${storySender}/${storyId}`;
|
return `https://www.instagram.com/stories/${storySender}/${storyId}`;
|
||||||
},
|
},
|
||||||
|
showStatusIndicators() {
|
||||||
|
if ((this.isOutgoing || this.isTemplate) && !this.private) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
},
|
||||||
showSentIndicator() {
|
showSentIndicator() {
|
||||||
return (
|
if (!this.showStatusIndicators) {
|
||||||
this.isOutgoing &&
|
return false;
|
||||||
this.sourceId &&
|
}
|
||||||
(this.isAnEmailChannel || (this.isAWhatsAppChannel && this.isSent))
|
|
||||||
);
|
if (this.isAnEmailChannel) {
|
||||||
|
return !!this.sourceId;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.isAWhatsAppChannel) {
|
||||||
|
return this.sourceId && this.isSent;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
},
|
},
|
||||||
showDeliveredIndicator() {
|
showDeliveredIndicator() {
|
||||||
return (
|
if (!this.showStatusIndicators) {
|
||||||
this.isOutgoing &&
|
return false;
|
||||||
this.sourceId &&
|
}
|
||||||
this.isAWhatsAppChannel &&
|
|
||||||
this.isDelivered
|
if (this.isAWhatsAppChannel) {
|
||||||
);
|
return this.sourceId && this.isDelivered;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
},
|
},
|
||||||
showReadIndicator() {
|
showReadIndicator() {
|
||||||
return (
|
if (!this.showStatusIndicators) {
|
||||||
this.isOutgoing &&
|
return false;
|
||||||
this.sourceId &&
|
}
|
||||||
this.isAWhatsAppChannel &&
|
|
||||||
this.isRead
|
if (this.isAWebWidgetInbox) {
|
||||||
);
|
const { contact_last_seen_at: contactLastSeenAt } = this.currentChat;
|
||||||
|
return contactLastSeenAt >= this.createdAt;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.isAWhatsAppChannel) {
|
||||||
|
return this.sourceId && this.isRead;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
@ -218,12 +253,13 @@ export default {
|
||||||
|
|
||||||
.action--icon {
|
.action--icon {
|
||||||
color: var(--white);
|
color: var(--white);
|
||||||
|
|
||||||
&.read-tick {
|
&.read-tick {
|
||||||
color: var(--v-100);
|
color: var(--v-100);
|
||||||
}
|
}
|
||||||
|
|
||||||
&.read-indicator {
|
&.read-indicator {
|
||||||
color: var(--g-300);
|
color: var(--g-200);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -288,8 +324,9 @@ export default {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
right: var(--space-small);
|
right: var(--space-small);
|
||||||
white-space: nowrap;
|
white-space: nowrap;
|
||||||
&.delivered {
|
|
||||||
right: var(--space-medium);
|
&.has-status-icon {
|
||||||
|
right: var(--space-large);
|
||||||
line-height: 2;
|
line-height: 2;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,10 +35,6 @@ export default {
|
||||||
type: String,
|
type: String,
|
||||||
default: '',
|
default: '',
|
||||||
},
|
},
|
||||||
readableTime: {
|
|
||||||
type: String,
|
|
||||||
default: '',
|
|
||||||
},
|
|
||||||
isEmail: {
|
isEmail: {
|
||||||
type: Boolean,
|
type: Boolean,
|
||||||
default: true,
|
default: true,
|
||||||
|
|
|
@ -34,9 +34,6 @@ export default {
|
||||||
lastNonActivityMessageFromAPI
|
lastNonActivityMessageFromAPI
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
hasUserReadMessage(createdAt, contactLastSeen) {
|
|
||||||
return !(contactLastSeen - createdAt < 0);
|
|
||||||
},
|
|
||||||
readMessages(m) {
|
readMessages(m) {
|
||||||
return m.messages.filter(
|
return m.messages.filter(
|
||||||
chat => chat.created_at * 1000 <= m.agent_last_seen_at * 1000
|
chat => chat.created_at * 1000 <= m.agent_last_seen_at * 1000
|
||||||
|
|
Loading…
Reference in a new issue