From 3bd4570580026639fda54d548bb503346bbff3be Mon Sep 17 00:00:00 2001 From: Shivam Mishra Date: Wed, 8 Apr 2026 20:53:08 +0530 Subject: [PATCH] feat: move inboxes get to provider --- .../react-components/src/components/ChatwootProvider.jsx | 9 ++++++++- app/javascript/ui/MessageList.vue | 1 - 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/app/javascript/react-components/src/components/ChatwootProvider.jsx b/app/javascript/react-components/src/components/ChatwootProvider.jsx index 5470bc89912..785ef0d97f5 100644 --- a/app/javascript/react-components/src/components/ChatwootProvider.jsx +++ b/app/javascript/react-components/src/components/ChatwootProvider.jsx @@ -78,7 +78,14 @@ export const ChatwootProvider = ({ window.axios = createAxios(axios); // Initialize user in store and ActionCable - store.dispatch('setUser').then(() => { + store.dispatch('setUser').then(async () => { + // Fetch inboxes once per session. Guarded against the shared Vuex store + // so remounting the provider (e.g. when the consumer re-keys per + // conversation) doesn't trigger redundant /inboxes requests. + const hasInboxes = store.getters['inboxes/getInboxes'].length > 0; + if (!hasInboxes) { + await store.dispatch('inboxes/get'); + } vueActionCable.init(store, config.pubsubToken); setInitializationComplete(true); }); diff --git a/app/javascript/ui/MessageList.vue b/app/javascript/ui/MessageList.vue index 284f0421fe4..6a0d9ce84b9 100644 --- a/app/javascript/ui/MessageList.vue +++ b/app/javascript/ui/MessageList.vue @@ -74,7 +74,6 @@ const fetchMore = async () => { }; onMounted(async () => { - await store.dispatch('inboxes/get'); await Promise.all([ store.dispatch('getConversation', conversationId.value), store.dispatch('fetchAllAttachments', conversationId.value),