@@ -4,6 +4,7 @@ import getters, { getSelectedChatConversation } from './getters';
|
|||||||
import actions from './actions';
|
import actions from './actions';
|
||||||
import { findPendingMessageIndex } from './helpers';
|
import { findPendingMessageIndex } from './helpers';
|
||||||
import wootConstants from '../../../constants';
|
import wootConstants from '../../../constants';
|
||||||
|
import { BUS_EVENTS } from '../../../../shared/constants/busEvents';
|
||||||
|
|
||||||
const state = {
|
const state = {
|
||||||
allConversations: [],
|
allConversations: [],
|
||||||
@@ -108,7 +109,7 @@ export const mutations = {
|
|||||||
chat.messages.push(message);
|
chat.messages.push(message);
|
||||||
chat.timestamp = message.created_at;
|
chat.timestamp = message.created_at;
|
||||||
if (selectedChatId === conversationId) {
|
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);
|
Vue.set(allConversations, currentConversationIndex, currentConversation);
|
||||||
if (_state.selectedChatId === conversation.id) {
|
if (_state.selectedChatId === conversation.id) {
|
||||||
window.bus.$emit('scrollToMessage');
|
window.bus.$emit(BUS_EVENTS.SCROLL_TO_MESSAGE);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
_state.allConversations.push(conversation);
|
_state.allConversations.push(conversation);
|
||||||
|
|||||||
@@ -120,7 +120,7 @@ describe('#mutations', () => {
|
|||||||
timestamp: 1602256198,
|
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', () => {
|
it('update message if it exist in the store', () => {
|
||||||
|
|||||||
Reference in New Issue
Block a user