fix: Prevent race condition in conversation dataFetched flag (#13492)
Co-authored-by: Shivam Mishra <scm.mymail@gmail.com>
This commit is contained in:
@@ -96,7 +96,7 @@ const actions = {
|
||||
data: payload,
|
||||
});
|
||||
if (!payload.length) {
|
||||
commit(types.SET_ALL_MESSAGES_LOADED);
|
||||
commit(types.SET_ALL_MESSAGES_LOADED, data.conversationId);
|
||||
}
|
||||
} catch (error) {
|
||||
// Handle error
|
||||
@@ -191,7 +191,7 @@ const actions = {
|
||||
|
||||
async setActiveChat({ commit, dispatch }, { data, after }) {
|
||||
commit(types.SET_CURRENT_CHAT_WINDOW, data);
|
||||
commit(types.CLEAR_ALL_MESSAGES_LOADED);
|
||||
commit(types.CLEAR_ALL_MESSAGES_LOADED, data.id);
|
||||
if (data.dataFetched === undefined) {
|
||||
try {
|
||||
await dispatch('fetchPreviousMessages', {
|
||||
@@ -199,7 +199,7 @@ const actions = {
|
||||
before: data.messages[0].id,
|
||||
conversationId: data.id,
|
||||
});
|
||||
data.dataFetched = true;
|
||||
commit(types.SET_CHAT_DATA_FETCHED, data.id);
|
||||
} catch (error) {
|
||||
// Ignore error
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user