diff --git a/app/javascript/dashboard/store/modules/conversations/index.js b/app/javascript/dashboard/store/modules/conversations/index.js index c8519c253..87d81d070 100644 --- a/app/javascript/dashboard/store/modules/conversations/index.js +++ b/app/javascript/dashboard/store/modules/conversations/index.js @@ -4,6 +4,7 @@ import getters, { getSelectedChatConversation } from './getters'; import actions from './actions'; import { findPendingMessageIndex } from './helpers'; import wootConstants from '../../../constants'; +import { BUS_EVENTS } from '../../../../shared/constants/busEvents'; const state = { allConversations: [], @@ -108,7 +109,7 @@ export const mutations = { chat.messages.push(message); chat.timestamp = message.created_at; if (selectedChatId === conversationId) { - window.bus.$emit('scrollToMessage'); + window.bus.$emit(BUS_EVENTS.SCROLL_TO_MESSAGE); } } }, @@ -130,7 +131,7 @@ export const mutations = { }; Vue.set(allConversations, currentConversationIndex, currentConversation); if (_state.selectedChatId === conversation.id) { - window.bus.$emit('scrollToMessage'); + window.bus.$emit(BUS_EVENTS.SCROLL_TO_MESSAGE); } } else { _state.allConversations.push(conversation); diff --git a/app/javascript/dashboard/store/modules/specs/conversations/mutations.spec.js b/app/javascript/dashboard/store/modules/specs/conversations/mutations.spec.js index cc08939d0..b7828fff3 100644 --- a/app/javascript/dashboard/store/modules/specs/conversations/mutations.spec.js +++ b/app/javascript/dashboard/store/modules/specs/conversations/mutations.spec.js @@ -120,7 +120,7 @@ describe('#mutations', () => { timestamp: 1602256198, }, ]); - expect(global.bus.$emit).toHaveBeenCalledWith('scrollToMessage'); + expect(global.bus.$emit).toHaveBeenCalledWith('SCROLL_TO_MESSAGE'); }); it('update message if it exist in the store', () => {