fix: Prevent race condition in conversation dataFetched flag (#13492)
Co-authored-by: Shivam Mishra <scm.mymail@gmail.com>
This commit is contained in:
@@ -63,14 +63,18 @@ export const mutations = {
|
||||
_state.allConversations = [];
|
||||
_state.selectedChatId = null;
|
||||
},
|
||||
[types.SET_ALL_MESSAGES_LOADED](_state) {
|
||||
const [chat] = getSelectedChatConversation(_state);
|
||||
chat.allMessagesLoaded = true;
|
||||
[types.SET_ALL_MESSAGES_LOADED](_state, conversationId) {
|
||||
const chat = getConversationById(_state)(conversationId);
|
||||
if (chat) {
|
||||
chat.allMessagesLoaded = true;
|
||||
}
|
||||
},
|
||||
|
||||
[types.CLEAR_ALL_MESSAGES_LOADED](_state) {
|
||||
const [chat] = getSelectedChatConversation(_state);
|
||||
chat.allMessagesLoaded = false;
|
||||
[types.CLEAR_ALL_MESSAGES_LOADED](_state, conversationId) {
|
||||
const chat = getConversationById(_state)(conversationId);
|
||||
if (chat) {
|
||||
chat.allMessagesLoaded = false;
|
||||
}
|
||||
},
|
||||
[types.CLEAR_CURRENT_CHAT_WINDOW](_state) {
|
||||
_state.selectedChatId = null;
|
||||
@@ -91,6 +95,13 @@ export const mutations = {
|
||||
chat.messages = data;
|
||||
},
|
||||
|
||||
[types.SET_CHAT_DATA_FETCHED](_state, conversationId) {
|
||||
const chat = getConversationById(_state)(conversationId);
|
||||
if (chat) {
|
||||
chat.dataFetched = true;
|
||||
}
|
||||
},
|
||||
|
||||
[types.SET_CURRENT_CHAT_WINDOW](_state, activeChat) {
|
||||
if (activeChat) {
|
||||
_state.selectedChatId = activeChat.id;
|
||||
|
||||
Reference in New Issue
Block a user