fix: Update conversation read status indicator logic (#5777)
This commit is contained in:
@@ -139,7 +139,6 @@ export default {
|
|||||||
listLoadingStatus: 'getAllMessagesLoaded',
|
listLoadingStatus: 'getAllMessagesLoaded',
|
||||||
getUnreadCount: 'getUnreadCount',
|
getUnreadCount: 'getUnreadCount',
|
||||||
loadingChatList: 'getChatListLoadingStatus',
|
loadingChatList: 'getChatListLoadingStatus',
|
||||||
conversationLastSeen: 'getConversationLastSeen',
|
|
||||||
}),
|
}),
|
||||||
inboxId() {
|
inboxId() {
|
||||||
return this.currentChat.inbox_id;
|
return this.currentChat.inbox_id;
|
||||||
@@ -234,7 +233,6 @@ export default {
|
|||||||
return 'arrow-chevron-left';
|
return 'arrow-chevron-left';
|
||||||
},
|
},
|
||||||
getLastSeenAt() {
|
getLastSeenAt() {
|
||||||
if (this.conversationLastSeen) return this.conversationLastSeen;
|
|
||||||
const { contact_last_seen_at: contactLastSeenAt } = this.currentChat;
|
const { contact_last_seen_at: contactLastSeenAt } = this.currentChat;
|
||||||
return contactLastSeenAt;
|
return contactLastSeenAt;
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -68,8 +68,7 @@ class ActionCableConnector extends BaseActionCableConnector {
|
|||||||
};
|
};
|
||||||
|
|
||||||
onConversationRead = data => {
|
onConversationRead = data => {
|
||||||
const { contact_last_seen_at: lastSeen } = data;
|
this.app.$store.dispatch('updateConversation', data);
|
||||||
this.app.$store.dispatch('updateConversationRead', lastSeen);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
onLogout = () => AuthAPI.logout();
|
onLogout = () => AuthAPI.logout();
|
||||||
|
|||||||
@@ -26,11 +26,4 @@ describe('#conversationMixin', () => {
|
|||||||
conversationMixin.methods.unReadMessages(conversationFixture.conversation)
|
conversationMixin.methods.unReadMessages(conversationFixture.conversation)
|
||||||
).toEqual(conversationFixture.unReadMessages);
|
).toEqual(conversationFixture.unReadMessages);
|
||||||
});
|
});
|
||||||
it('should return the user message read flag', () => {
|
|
||||||
const contactLastSeen = 1649856659;
|
|
||||||
const createdAt = 1649859419;
|
|
||||||
expect(
|
|
||||||
conversationMixin.methods.hasUserReadMessage(createdAt, contactLastSeen)
|
|
||||||
).toEqual(false);
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -199,10 +199,6 @@ const actions = {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
updateConversationRead({ commit }, timestamp) {
|
|
||||||
commit(types.SET_CONVERSATION_LAST_SEEN, timestamp);
|
|
||||||
},
|
|
||||||
|
|
||||||
updateMessage({ commit }, message) {
|
updateMessage({ commit }, message) {
|
||||||
commit(types.ADD_MESSAGE, message);
|
commit(types.ADD_MESSAGE, message);
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -91,9 +91,6 @@ const getters = {
|
|||||||
value => value.id === Number(conversationId)
|
value => value.id === Number(conversationId)
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
getConversationLastSeen: _state => {
|
|
||||||
return _state.conversationLastSeen;
|
|
||||||
},
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export default getters;
|
export default getters;
|
||||||
|
|||||||
@@ -13,7 +13,6 @@ const state = {
|
|||||||
currentInbox: null,
|
currentInbox: null,
|
||||||
selectedChatId: null,
|
selectedChatId: null,
|
||||||
appliedFilters: [],
|
appliedFilters: [],
|
||||||
conversationLastSeen: null,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// mutations
|
// mutations
|
||||||
@@ -34,9 +33,6 @@ export const mutations = {
|
|||||||
_state.allConversations = [];
|
_state.allConversations = [];
|
||||||
_state.selectedChatId = null;
|
_state.selectedChatId = null;
|
||||||
},
|
},
|
||||||
[types.SET_CONVERSATION_LAST_SEEN](_state, timestamp) {
|
|
||||||
_state.conversationLastSeen = timestamp;
|
|
||||||
},
|
|
||||||
[types.SET_ALL_MESSAGES_LOADED](_state) {
|
[types.SET_ALL_MESSAGES_LOADED](_state) {
|
||||||
const [chat] = getSelectedChatConversation(_state);
|
const [chat] = getSelectedChatConversation(_state);
|
||||||
Vue.set(chat, 'allMessagesLoaded', true);
|
Vue.set(chat, 'allMessagesLoaded', true);
|
||||||
|
|||||||
@@ -380,15 +380,6 @@ describe('#actions', () => {
|
|||||||
expect(commit.mock.calls).toEqual([[types.CLEAR_CONVERSATION_FILTERS]]);
|
expect(commit.mock.calls).toEqual([[types.CLEAR_CONVERSATION_FILTERS]]);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('#updateConversationRead', () => {
|
|
||||||
it('commits the correct mutation and sets the contact_last_seen', () => {
|
|
||||||
actions.updateConversationRead({ commit }, 1649856659);
|
|
||||||
expect(commit.mock.calls).toEqual([
|
|
||||||
[types.SET_CONVERSATION_LAST_SEEN, 1649856659],
|
|
||||||
]);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('#deleteMessage', () => {
|
describe('#deleteMessage', () => {
|
||||||
|
|||||||
@@ -132,16 +132,6 @@ describe('#getters', () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('#getConversationLastSeen', () => {
|
|
||||||
it('getConversationLastSeen', () => {
|
|
||||||
const timestamp = 1649856659;
|
|
||||||
const state = {
|
|
||||||
conversationLastSeen: timestamp,
|
|
||||||
};
|
|
||||||
expect(getters.getConversationLastSeen(state)).toEqual(timestamp);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('#getLastEmailInSelectedChat', () => {
|
describe('#getLastEmailInSelectedChat', () => {
|
||||||
it('Returns cc in last email', () => {
|
it('Returns cc in last email', () => {
|
||||||
const state = {};
|
const state = {};
|
||||||
|
|||||||
@@ -200,18 +200,6 @@ describe('#mutations', () => {
|
|||||||
]);
|
]);
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('#SET_CONVERSATION_LAST_SEEN', () => {
|
|
||||||
it('sets conversation last seen timestamp', () => {
|
|
||||||
const state = {
|
|
||||||
conversationLastSeen: null,
|
|
||||||
};
|
|
||||||
|
|
||||||
mutations[types.SET_CONVERSATION_LAST_SEEN](state, 1649856659);
|
|
||||||
|
|
||||||
expect(state.conversationLastSeen).toEqual(1649856659);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('#UPDATE_CONVERSATION_CUSTOM_ATTRIBUTES', () => {
|
describe('#UPDATE_CONVERSATION_CUSTOM_ATTRIBUTES', () => {
|
||||||
it('update conversation custom attributes', () => {
|
it('update conversation custom attributes', () => {
|
||||||
const custom_attributes = { order_id: 1001 };
|
const custom_attributes = { order_id: 1001 };
|
||||||
|
|||||||
@@ -21,7 +21,6 @@ export default {
|
|||||||
CLEAR_CONTACT_CONVERSATIONS: 'CLEAR_CONTACT_CONVERSATIONS',
|
CLEAR_CONTACT_CONVERSATIONS: 'CLEAR_CONTACT_CONVERSATIONS',
|
||||||
SET_CONVERSATION_FILTERS: 'SET_CONVERSATION_FILTERS',
|
SET_CONVERSATION_FILTERS: 'SET_CONVERSATION_FILTERS',
|
||||||
CLEAR_CONVERSATION_FILTERS: 'CLEAR_CONVERSATION_FILTERS',
|
CLEAR_CONVERSATION_FILTERS: 'CLEAR_CONVERSATION_FILTERS',
|
||||||
SET_CONVERSATION_LAST_SEEN: 'SET_CONVERSATION_LAST_SEEN',
|
|
||||||
|
|
||||||
SET_CURRENT_CHAT_WINDOW: 'SET_CURRENT_CHAT_WINDOW',
|
SET_CURRENT_CHAT_WINDOW: 'SET_CURRENT_CHAT_WINDOW',
|
||||||
CLEAR_CURRENT_CHAT_WINDOW: 'CLEAR_CURRENT_CHAT_WINDOW',
|
CLEAR_CURRENT_CHAT_WINDOW: 'CLEAR_CURRENT_CHAT_WINDOW',
|
||||||
|
|||||||
Reference in New Issue
Block a user