diff --git a/app/javascript/widget/App.vue b/app/javascript/widget/App.vue index 2f2113b57..ef9d63aac 100755 --- a/app/javascript/widget/App.vue +++ b/app/javascript/widget/App.vue @@ -36,6 +36,7 @@ export default { widgetPosition: 'right', showPopoutButton: false, isWebWidgetTriggered: false, + isWidgetOpen: false, }; }, computed: { @@ -134,8 +135,8 @@ export default { this.hideMessageBubble = !!hideBubble; }, registerUnreadEvents() { - bus.$on('on-agent-message-recieved', () => { - if (!this.isIFrame) { + bus.$on('on-agent-message-received', () => { + if (!this.isIFrame || this.isWidgetOpen) { this.setUserLastSeen(); } this.setUnreadView(); @@ -257,6 +258,7 @@ export default { this.showUnreadView = false; this.showCampaignView = false; } else if (message.event === 'toggle-open') { + this.isWidgetOpen = message.isOpen; this.toggleOpen(); } }); diff --git a/app/javascript/widget/helpers/actionCable.js b/app/javascript/widget/helpers/actionCable.js index 32bdd644f..c4cf483c6 100644 --- a/app/javascript/widget/helpers/actionCable.js +++ b/app/javascript/widget/helpers/actionCable.js @@ -34,7 +34,7 @@ class ActionCableConnector extends BaseActionCableConnector { this.app.$store .dispatch('conversation/addOrUpdateMessage', data) .then(() => { - window.bus.$emit('on-agent-message-recieved'); + window.bus.$emit('on-agent-message-received'); }); };