Skip to content

Commit

Permalink
fix: Update the chat button class when the user status is updated - E…
Browse files Browse the repository at this point in the history
…XO-66137 (#707) (#710)

Prior to this change after updating the user status the chat button color was not updated , this change is going to add a document event listener to update the chat button class when the user's status updated
  • Loading branch information
sofyenne authored Feb 8, 2024
1 parent 4224470 commit 2e2d045
Showing 1 changed file with 19 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<v-btn
id="btnChatButton"
class="dropdown-toggle"
:class="statusClass()"
:class="statusClass"
:title="$t('Notification.chat.button.tooltip')"
@click="openChatDrawer"
icon>
Expand All @@ -31,6 +31,15 @@ export default {
totalUnreadMsg: 0,
};
},
computed: {
statusClass() {
if (this.userSettings.status === 'invisible') {
return 'user-offline';
} else {
return `user-${this.userSettings.status}`;
}
},
},
watch: {
totalUnreadMsg() {
chatServices.updateTotalUnread(this.totalUnreadMsg);
Expand All @@ -41,9 +50,11 @@ export default {
this.initSettings(userSettings);
});
document.addEventListener(chatConstants.EVENT_GLOBAL_UNREAD_COUNT_UPDATED, this.totalUnreadMessagesUpdated);
document.addEventListener(chatConstants.EVENT_USER_STATUS_CHANGED, this.userStatusChanged);
},
destroyed() {
document.removeEventListener(chatConstants.EVENT_GLOBAL_UNREAD_COUNT_UPDATED, this.totalUnreadMessagesUpdated);
document.removeEventListener(chatConstants.EVENT_USER_STATUS_CHANGED, this.userStatusChanged);
},
methods: {
totalUnreadMessagesUpdated(e) {
Expand Down Expand Up @@ -74,21 +85,20 @@ export default {
canShowOnSiteNotif() {
return desktopNotification.canShowOnSiteNotif();
},
statusClass() {
if (this.userSettings.status === 'invisible') {
return 'user-offline';
} else {
return `user-${this.userSettings.status}`;
}
},
openChatDrawer(event){
if (event){
event.preventDefault();
event.stopPropagation();
}
document.dispatchEvent(new CustomEvent(chatConstants.ACTION_CHAT_OPEN_DRAWER));
}
},
userStatusChanged(e) {
const changedUser = e.detail;
if (this.userSettings.username === changedUser.sender) {
this.userSettings.status = changedUser.status ? changedUser.status : changedUser.data ? changedUser.data.status : null;
}
},
}
};
</script>

0 comments on commit 2e2d045

Please sign in to comment.