fix: Update conversation read status indicator logic (#5777)
This commit is contained in:
parent
a0606d36f6
commit
92724576af
10 changed files with 1 additions and 54 deletions
|
@ -139,7 +139,6 @@ export default {
|
|||
listLoadingStatus: 'getAllMessagesLoaded',
|
||||
getUnreadCount: 'getUnreadCount',
|
||||
loadingChatList: 'getChatListLoadingStatus',
|
||||
conversationLastSeen: 'getConversationLastSeen',
|
||||
}),
|
||||
inboxId() {
|
||||
return this.currentChat.inbox_id;
|
||||
|
@ -234,7 +233,6 @@ export default {
|
|||
return 'arrow-chevron-left';
|
||||
},
|
||||
getLastSeenAt() {
|
||||
if (this.conversationLastSeen) return this.conversationLastSeen;
|
||||
const { contact_last_seen_at: contactLastSeenAt } = this.currentChat;
|
||||
return contactLastSeenAt;
|
||||
},
|
||||
|
|
|
@ -68,8 +68,7 @@ class ActionCableConnector extends BaseActionCableConnector {
|
|||
};
|
||||
|
||||
onConversationRead = data => {
|
||||
const { contact_last_seen_at: lastSeen } = data;
|
||||
this.app.$store.dispatch('updateConversationRead', lastSeen);
|
||||
this.app.$store.dispatch('updateConversation', data);
|
||||
};
|
||||
|
||||
onLogout = () => AuthAPI.logout();
|
||||
|
|
|
@ -26,11 +26,4 @@ describe('#conversationMixin', () => {
|
|||
conversationMixin.methods.unReadMessages(conversationFixture.conversation)
|
||||
).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) {
|
||||
commit(types.ADD_MESSAGE, message);
|
||||
},
|
||||
|
|
|
@ -91,9 +91,6 @@ const getters = {
|
|||
value => value.id === Number(conversationId)
|
||||
);
|
||||
},
|
||||
getConversationLastSeen: _state => {
|
||||
return _state.conversationLastSeen;
|
||||
},
|
||||
};
|
||||
|
||||
export default getters;
|
||||
|
|
|
@ -13,7 +13,6 @@ const state = {
|
|||
currentInbox: null,
|
||||
selectedChatId: null,
|
||||
appliedFilters: [],
|
||||
conversationLastSeen: null,
|
||||
};
|
||||
|
||||
// mutations
|
||||
|
@ -34,9 +33,6 @@ export const mutations = {
|
|||
_state.allConversations = [];
|
||||
_state.selectedChatId = null;
|
||||
},
|
||||
[types.SET_CONVERSATION_LAST_SEEN](_state, timestamp) {
|
||||
_state.conversationLastSeen = timestamp;
|
||||
},
|
||||
[types.SET_ALL_MESSAGES_LOADED](_state) {
|
||||
const [chat] = getSelectedChatConversation(_state);
|
||||
Vue.set(chat, 'allMessagesLoaded', true);
|
||||
|
|
|
@ -380,15 +380,6 @@ describe('#actions', () => {
|
|||
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', () => {
|
||||
|
|
|
@ -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', () => {
|
||||
it('Returns cc in last email', () => {
|
||||
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', () => {
|
||||
it('update conversation custom attributes', () => {
|
||||
const custom_attributes = { order_id: 1001 };
|
||||
|
|
|
@ -21,7 +21,6 @@ export default {
|
|||
CLEAR_CONTACT_CONVERSATIONS: 'CLEAR_CONTACT_CONVERSATIONS',
|
||||
SET_CONVERSATION_FILTERS: 'SET_CONVERSATION_FILTERS',
|
||||
CLEAR_CONVERSATION_FILTERS: 'CLEAR_CONVERSATION_FILTERS',
|
||||
SET_CONVERSATION_LAST_SEEN: 'SET_CONVERSATION_LAST_SEEN',
|
||||
|
||||
SET_CURRENT_CHAT_WINDOW: 'SET_CURRENT_CHAT_WINDOW',
|
||||
CLEAR_CURRENT_CHAT_WINDOW: 'CLEAR_CURRENT_CHAT_WINDOW',
|
||||
|
|
Loading…
Reference in a new issue