feat: move inboxes get to provider

This commit is contained in:
Shivam Mishra 2026-04-08 20:53:08 +05:30
parent fb75f8783f
commit 3bd4570580
No known key found for this signature in database
2 changed files with 8 additions and 2 deletions

View File

@ -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);
});

View File

@ -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),