From 5b4d3c1f8397665d422f324431f0907b963b04a5 Mon Sep 17 00:00:00 2001 From: Shivam Mishra Date: Wed, 22 Apr 2026 19:05:26 +0530 Subject: [PATCH] fix: setactivechat last message --- .../store/modules/conversations/actions.js | 26 +++++++++++++++---- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/app/javascript/dashboard/store/modules/conversations/actions.js b/app/javascript/dashboard/store/modules/conversations/actions.js index c6a197d85..9e187b42f 100644 --- a/app/javascript/dashboard/store/modules/conversations/actions.js +++ b/app/javascript/dashboard/store/modules/conversations/actions.js @@ -192,17 +192,33 @@ const actions = { async setActiveChat({ commit, dispatch }, { data, after }) { commit(types.SET_CURRENT_CHAT_WINDOW, data); commit(types.CLEAR_ALL_MESSAGES_LOADED, data.id); - if (data.dataFetched === undefined) { - try { + try { + if (data.dataFetched === undefined) { await dispatch('fetchPreviousMessages', { after, - before: data.messages[0].id, + before: data.messages?.[0]?.id, conversationId: data.id, }); commit(types.SET_CHAT_DATA_FETCHED, data.id); - } catch (error) { - // Ignore error } + // Embedded UI (react-components) has no ReconnectService, so messages + // that arrive while the ActionCable socket is disconnected — or between + // the initial `getConversation` fetch and component mount — never land + // in the store and silently fail to render. Stamp the current tail and + // pull anything newer from the API so the message list stays in sync + // without relying on the websocket. The dashboard skips this because + // ReconnectService already handles it on reconnect. + // eslint-disable-next-line no-underscore-dangle + if (window.__WOOT_ISOLATED_SHELL__) { + await dispatch('setConversationLastMessageId', { + conversationId: data.id, + }); + await dispatch('syncActiveConversationMessages', { + conversationId: data.id, + }); + } + } catch (error) { + // Ignore error } },