fix: hydrate realtime conversations before rendering
Build and publish Docker images / Build and publish images (push) Successful in 3m16s

This commit is contained in:
2026-09-14 21:39:56 +08:00
parent 9b8d575657
commit 5a0e9ecada
4 changed files with 149 additions and 10 deletions
@@ -51,10 +51,19 @@ const actions = {
getConversation: async ({ commit }, conversationId) => {
try {
const response = await ConversationApi.show(conversationId);
commit(types.UPDATE_CONVERSATION, response.data);
commit(`contacts/${types.SET_CONTACT_ITEM}`, response.data.meta.sender);
const conversation = response.data;
commit(types.UPDATE_CONVERSATION, conversation);
if (Array.isArray(conversation.messages)) {
commit(types.SET_MISSING_MESSAGES, {
id: conversation.id,
data: conversation.messages,
});
}
commit(`contacts/${types.SET_CONTACT_ITEM}`, conversation.meta.sender);
return conversation;
} catch (error) {
// Ignore error
return null;
}
},
@@ -225,11 +234,16 @@ const actions = {
commit(types.CLEAR_ALL_MESSAGES_LOADED, data.id);
if (data.dataFetched === undefined) {
try {
await dispatch('fetchPreviousMessages', {
after,
before: data.messages[0].id,
conversationId: data.id,
});
if (!data.messages?.length) {
const conversation = await dispatch('getConversation', data.id);
if (!conversation) return;
} else {
await dispatch('fetchPreviousMessages', {
after,
before: data.messages[0].id,
conversationId: data.id,
});
}
commit(types.SET_CHAT_DATA_FETCHED, data.id);
} catch (error) {
// Ignore error
@@ -435,7 +449,9 @@ const actions = {
) {
commit(types.ADD_CONVERSATION, conversation);
dispatch('contacts/setContact', sender);
return true;
}
return false;
},
addMentions({ dispatch, rootState }, conversation) {