diff --git a/app/javascript/v3/components/SnackBar/Container.vue b/app/javascript/v3/components/SnackBar/Container.vue index 592fb02e2..683480af6 100644 --- a/app/javascript/v3/components/SnackBar/Container.vue +++ b/app/javascript/v3/components/SnackBar/Container.vue @@ -33,10 +33,10 @@ export default { }, mounted() { - bus.$on(BUS_EVENTS.SHOW_TOAST, this.onNewToastMessage); + this.$emitter.on(BUS_EVENTS.SHOW_TOAST, this.onNewToastMessage); }, beforeDestroy() { - bus.$off(BUS_EVENTS.SHOW_TOAST, this.onNewToastMessage); + this.$emitter.off(BUS_EVENTS.SHOW_TOAST, this.onNewToastMessage); }, methods: { onNewToastMessage(message, action) { diff --git a/app/javascript/widget/components/ChatFooter.vue b/app/javascript/widget/components/ChatFooter.vue index 33f6f2f8c..7d755ef68 100755 --- a/app/javascript/widget/components/ChatFooter.vue +++ b/app/javascript/widget/components/ChatFooter.vue @@ -99,7 +99,7 @@ export default { }, }, mounted() { - bus.$on(BUS_EVENTS.TOGGLE_REPLY_TO_MESSAGE, this.toggleReplyTo); + this.$emitter.on(BUS_EVENTS.TOGGLE_REPLY_TO_MESSAGE, this.toggleReplyTo); }, methods: { ...mapActions('conversation', [ diff --git a/app/javascript/widget/components/UnreadMessage.vue b/app/javascript/widget/components/UnreadMessage.vue index 19e757973..cefd0cc99 100644 --- a/app/javascript/widget/components/UnreadMessage.vue +++ b/app/javascript/widget/components/UnreadMessage.vue @@ -97,9 +97,9 @@ export default { }, onClickMessage() { if (this.campaignId) { - bus.$emit(ON_CAMPAIGN_MESSAGE_CLICK, this.campaignId); + this.$emitter.emit(ON_CAMPAIGN_MESSAGE_CLICK, this.campaignId); } else { - bus.$emit(ON_UNREAD_MESSAGE_CLICK); + this.$emitter.emit(ON_UNREAD_MESSAGE_CLICK); } }, }, diff --git a/app/javascript/widget/components/UnreadMessageList.vue b/app/javascript/widget/components/UnreadMessageList.vue index 4ea9e3f00..875457c42 100644 --- a/app/javascript/widget/components/UnreadMessageList.vue +++ b/app/javascript/widget/components/UnreadMessageList.vue @@ -80,7 +80,7 @@ export default { }, methods: { openConversationView() { - bus.$emit(ON_UNREAD_MESSAGE_CLICK); + this.$emitter.emit(ON_UNREAD_MESSAGE_CLICK); }, closeFullView() { this.$emit('close'); diff --git a/app/javascript/widget/components/UserMessage.vue b/app/javascript/widget/components/UserMessage.vue index 812d699cb..0631b2f90 100755 --- a/app/javascript/widget/components/UserMessage.vue +++ b/app/javascript/widget/components/UserMessage.vue @@ -159,7 +159,7 @@ export default { this.hasImageError = true; }, toggleReply() { - bus.$emit(BUS_EVENTS.TOGGLE_REPLY_TO_MESSAGE, this.message); + this.$emitter.emit(BUS_EVENTS.TOGGLE_REPLY_TO_MESSAGE, this.message); }, }, }; diff --git a/app/javascript/widget/store/modules/conversation/actions.js b/app/javascript/widget/store/modules/conversation/actions.js index e1862ea84..f00f049ac 100644 --- a/app/javascript/widget/store/modules/conversation/actions.js +++ b/app/javascript/widget/store/modules/conversation/actions.js @@ -12,7 +12,7 @@ import { import { ON_CONVERSATION_CREATED } from 'widget/constants/widgetBusEvents'; import { createTemporaryMessage, getNonDeletedMessages } from './helpers'; - +import { emitter } from 'shared/helpers/mitt'; export const actions = { createConversation: async ({ commit, dispatch }, params) => { commit('setConversationUIFlag', { isCreating: true }); @@ -23,7 +23,7 @@ export const actions = { commit('pushMessageToConversation', message); dispatch('conversationAttributes/getAttributes', {}, { root: true }); // Emit event to notify that conversation is created and show the chat screen - bus.$emit(ON_CONVERSATION_CREATED); + emitter.emit(ON_CONVERSATION_CREATED); } catch (error) { // Ignore error } finally { diff --git a/app/javascript/widget/views/Campaigns.vue b/app/javascript/widget/views/Campaigns.vue index 2552c6f43..d28d0e4f4 100644 --- a/app/javascript/widget/views/Campaigns.vue +++ b/app/javascript/widget/views/Campaigns.vue @@ -32,7 +32,7 @@ export default { event: 'setCampaignReadOn', }); IFrameHelper.sendMessage({ event: 'toggleBubble' }); - bus.$emit('snooze-campaigns'); + this.$emitter.emit('snooze-campaigns'); } }, }, diff --git a/app/javascript/widget/views/PreChatForm.vue b/app/javascript/widget/views/PreChatForm.vue index 2f03521ba..254782db7 100644 --- a/app/javascript/widget/views/PreChatForm.vue +++ b/app/javascript/widget/views/PreChatForm.vue @@ -16,7 +16,7 @@ export default { }, mixins: [configMixin, routerMixin], mounted() { - bus.$on(ON_CONVERSATION_CREATED, () => { + this.$emitter.on(ON_CONVERSATION_CREATED, () => { // Redirect to messages page after conversation is created this.replaceRoute('messages'); }); @@ -32,7 +32,7 @@ export default { conversationCustomAttributes, }) { if (activeCampaignId) { - bus.$emit('execute-campaign', { + this.$emitter.emit('execute-campaign', { campaignId: activeCampaignId, customAttributes: conversationCustomAttributes, });