fix: Replace the bus events with emitter in widget (#9584)
Co-authored-by: Muhsin Keloth <muhsinkeramam@gmail.com>
This commit is contained in:
@@ -33,10 +33,10 @@ export default {
|
|||||||
},
|
},
|
||||||
|
|
||||||
mounted() {
|
mounted() {
|
||||||
bus.$on(BUS_EVENTS.SHOW_TOAST, this.onNewToastMessage);
|
this.$emitter.on(BUS_EVENTS.SHOW_TOAST, this.onNewToastMessage);
|
||||||
},
|
},
|
||||||
beforeDestroy() {
|
beforeDestroy() {
|
||||||
bus.$off(BUS_EVENTS.SHOW_TOAST, this.onNewToastMessage);
|
this.$emitter.off(BUS_EVENTS.SHOW_TOAST, this.onNewToastMessage);
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
onNewToastMessage(message, action) {
|
onNewToastMessage(message, action) {
|
||||||
|
|||||||
@@ -99,7 +99,7 @@ export default {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
mounted() {
|
mounted() {
|
||||||
bus.$on(BUS_EVENTS.TOGGLE_REPLY_TO_MESSAGE, this.toggleReplyTo);
|
this.$emitter.on(BUS_EVENTS.TOGGLE_REPLY_TO_MESSAGE, this.toggleReplyTo);
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
...mapActions('conversation', [
|
...mapActions('conversation', [
|
||||||
|
|||||||
@@ -97,9 +97,9 @@ export default {
|
|||||||
},
|
},
|
||||||
onClickMessage() {
|
onClickMessage() {
|
||||||
if (this.campaignId) {
|
if (this.campaignId) {
|
||||||
bus.$emit(ON_CAMPAIGN_MESSAGE_CLICK, this.campaignId);
|
this.$emitter.emit(ON_CAMPAIGN_MESSAGE_CLICK, this.campaignId);
|
||||||
} else {
|
} else {
|
||||||
bus.$emit(ON_UNREAD_MESSAGE_CLICK);
|
this.$emitter.emit(ON_UNREAD_MESSAGE_CLICK);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -80,7 +80,7 @@ export default {
|
|||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
openConversationView() {
|
openConversationView() {
|
||||||
bus.$emit(ON_UNREAD_MESSAGE_CLICK);
|
this.$emitter.emit(ON_UNREAD_MESSAGE_CLICK);
|
||||||
},
|
},
|
||||||
closeFullView() {
|
closeFullView() {
|
||||||
this.$emit('close');
|
this.$emit('close');
|
||||||
|
|||||||
@@ -159,7 +159,7 @@ export default {
|
|||||||
this.hasImageError = true;
|
this.hasImageError = true;
|
||||||
},
|
},
|
||||||
toggleReply() {
|
toggleReply() {
|
||||||
bus.$emit(BUS_EVENTS.TOGGLE_REPLY_TO_MESSAGE, this.message);
|
this.$emitter.emit(BUS_EVENTS.TOGGLE_REPLY_TO_MESSAGE, this.message);
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ import {
|
|||||||
|
|
||||||
import { ON_CONVERSATION_CREATED } from 'widget/constants/widgetBusEvents';
|
import { ON_CONVERSATION_CREATED } from 'widget/constants/widgetBusEvents';
|
||||||
import { createTemporaryMessage, getNonDeletedMessages } from './helpers';
|
import { createTemporaryMessage, getNonDeletedMessages } from './helpers';
|
||||||
|
import { emitter } from 'shared/helpers/mitt';
|
||||||
export const actions = {
|
export const actions = {
|
||||||
createConversation: async ({ commit, dispatch }, params) => {
|
createConversation: async ({ commit, dispatch }, params) => {
|
||||||
commit('setConversationUIFlag', { isCreating: true });
|
commit('setConversationUIFlag', { isCreating: true });
|
||||||
@@ -23,7 +23,7 @@ export const actions = {
|
|||||||
commit('pushMessageToConversation', message);
|
commit('pushMessageToConversation', message);
|
||||||
dispatch('conversationAttributes/getAttributes', {}, { root: true });
|
dispatch('conversationAttributes/getAttributes', {}, { root: true });
|
||||||
// Emit event to notify that conversation is created and show the chat screen
|
// 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) {
|
} catch (error) {
|
||||||
// Ignore error
|
// Ignore error
|
||||||
} finally {
|
} finally {
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ export default {
|
|||||||
event: 'setCampaignReadOn',
|
event: 'setCampaignReadOn',
|
||||||
});
|
});
|
||||||
IFrameHelper.sendMessage({ event: 'toggleBubble' });
|
IFrameHelper.sendMessage({ event: 'toggleBubble' });
|
||||||
bus.$emit('snooze-campaigns');
|
this.$emitter.emit('snooze-campaigns');
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ export default {
|
|||||||
},
|
},
|
||||||
mixins: [configMixin, routerMixin],
|
mixins: [configMixin, routerMixin],
|
||||||
mounted() {
|
mounted() {
|
||||||
bus.$on(ON_CONVERSATION_CREATED, () => {
|
this.$emitter.on(ON_CONVERSATION_CREATED, () => {
|
||||||
// Redirect to messages page after conversation is created
|
// Redirect to messages page after conversation is created
|
||||||
this.replaceRoute('messages');
|
this.replaceRoute('messages');
|
||||||
});
|
});
|
||||||
@@ -32,7 +32,7 @@ export default {
|
|||||||
conversationCustomAttributes,
|
conversationCustomAttributes,
|
||||||
}) {
|
}) {
|
||||||
if (activeCampaignId) {
|
if (activeCampaignId) {
|
||||||
bus.$emit('execute-campaign', {
|
this.$emitter.emit('execute-campaign', {
|
||||||
campaignId: activeCampaignId,
|
campaignId: activeCampaignId,
|
||||||
customAttributes: conversationCustomAttributes,
|
customAttributes: conversationCustomAttributes,
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user