From 19c3eab9c90efec8a8af29892c084614db9a7295 Mon Sep 17 00:00:00 2001 From: Shivam Mishra Date: Fri, 7 Jul 2023 18:45:44 +0530 Subject: [PATCH] feat: fetch new suggestions when a message arrives --- .../dashboard/components/widgets/conversation/MessagesView.vue | 1 + app/javascript/dashboard/store/modules/conversations/index.js | 2 ++ app/javascript/shared/constants/busEvents.js | 1 + 3 files changed, 4 insertions(+) diff --git a/app/javascript/dashboard/components/widgets/conversation/MessagesView.vue b/app/javascript/dashboard/components/widgets/conversation/MessagesView.vue index 030f45f96..d9baa8cba 100644 --- a/app/javascript/dashboard/components/widgets/conversation/MessagesView.vue +++ b/app/javascript/dashboard/components/widgets/conversation/MessagesView.vue @@ -313,6 +313,7 @@ export default { created() { bus.$on(BUS_EVENTS.SCROLL_TO_MESSAGE, this.onScrollToMessage); + bus.$on(BUS_EVENTS.FETCH_LABEL_SUGGESTIONS, this.fetchSuggestions); bus.$on(BUS_EVENTS.SET_TWEET_REPLY, this.setSelectedTweet); }, diff --git a/app/javascript/dashboard/store/modules/conversations/index.js b/app/javascript/dashboard/store/modules/conversations/index.js index 96f431cbe..6bce92e02 100644 --- a/app/javascript/dashboard/store/modules/conversations/index.js +++ b/app/javascript/dashboard/store/modules/conversations/index.js @@ -179,6 +179,7 @@ export const mutations = { const { conversation: { unread_count: unreadCount = 0 } = {} } = message; chat.unread_count = unreadCount; if (selectedChatId === conversationId) { + window.bus.$emit(BUS_EVENTS.FETCH_LABEL_SUGGESTIONS); window.bus.$emit(BUS_EVENTS.SCROLL_TO_MESSAGE); } } @@ -201,6 +202,7 @@ export const mutations = { }; Vue.set(allConversations, currentConversationIndex, currentConversation); if (_state.selectedChatId === conversation.id) { + window.bus.$emit(BUS_EVENTS.FETCH_LABEL_SUGGESTIONS); window.bus.$emit(BUS_EVENTS.SCROLL_TO_MESSAGE); } } else { diff --git a/app/javascript/shared/constants/busEvents.js b/app/javascript/shared/constants/busEvents.js index 8ace54ef2..6456842e9 100644 --- a/app/javascript/shared/constants/busEvents.js +++ b/app/javascript/shared/constants/busEvents.js @@ -4,6 +4,7 @@ export const BUS_EVENTS = { START_NEW_CONVERSATION: 'START_NEW_CONVERSATION', FOCUS_CUSTOM_ATTRIBUTE: 'FOCUS_CUSTOM_ATTRIBUTE', SCROLL_TO_MESSAGE: 'SCROLL_TO_MESSAGE', + FETCH_LABEL_SUGGESTIONS: 'FETCH_LABEL_SUGGESTIONS', TOGGLE_SIDEMENU: 'TOGGLE_SIDEMENU', ON_MESSAGE_LIST_SCROLL: 'ON_MESSAGE_LIST_SCROLL', WEBSOCKET_DISCONNECT: 'WEBSOCKET_DISCONNECT',