diff --git a/app/javascript/widget/components/UnreadMessage.vue b/app/javascript/widget/components/UnreadMessage.vue
index 75fb5b05e..06d7ce8df 100644
--- a/app/javascript/widget/components/UnreadMessage.vue
+++ b/app/javascript/widget/components/UnreadMessage.vue
@@ -6,7 +6,7 @@
:src="avatarUrl"
size="20px"
:username="agentName"
- :status="sender.availability_status"
+ :status="availabilityStatus"
/>
{{ agentName }}
{{ companyName }}
@@ -46,34 +46,45 @@ export default {
}`;
},
avatarUrl() {
- const { avatar_url: avatarUrl } = this.sender;
// eslint-disable-next-line
const BotImage = require('dashboard/assets/images/chatwoot_bot.png');
const displayImage = this.useInboxAvatarForBot
? this.inboxAvatarUrl
: BotImage;
- return !isEmptyObject(this.sender) ? avatarUrl : displayImage;
+ if (this.isSenderExist(this.sender)) {
+ const { avatar_url: avatarUrl } = this.sender;
+ return avatarUrl;
+ }
+ return displayImage;
},
agentName() {
- const { available_name: availableName, name } = this.sender;
- if (!isEmptyObject(this.sender)) {
+ if (this.isSenderExist(this.sender)) {
+ const { available_name: availableName, name } = this.sender;
return availableName || name;
}
return this.$t('UNREAD_VIEW.BOT');
},
+ availabilityStatus() {
+ if (this.isSenderExist(this.sender)) {
+ const { availability_status: availabilityStatus } = this.sender;
+ return availabilityStatus;
+ }
+ return null;
+ },
+ },
+ methods: {
+ isSenderExist(sender) {
+ return sender && !isEmptyObject(sender);
+ },
},
};
-
-
-