feat: Display "Snoozed Until" time on conversation header (#3028)
This commit is contained in:
@@ -24,8 +24,9 @@ const actions = {
|
||||
commit(types.default.SET_LIST_LOADING_STATUS);
|
||||
try {
|
||||
const response = await ConversationApi.get(params);
|
||||
const { data } = response.data;
|
||||
const { payload: chatList, meta: metaData } = data;
|
||||
const {
|
||||
data: { payload: chatList, meta: metaData },
|
||||
} = response.data;
|
||||
commit(types.default.SET_ALL_CONVERSATION, chatList);
|
||||
dispatch('conversationStats/set', metaData);
|
||||
dispatch('conversationLabels/setBulkConversationLabels', chatList);
|
||||
@@ -36,10 +37,7 @@ const actions = {
|
||||
);
|
||||
dispatch(
|
||||
'conversationPage/setCurrentPage',
|
||||
{
|
||||
filter: params.assigneeType,
|
||||
page: params.page,
|
||||
},
|
||||
{ filter: params.assigneeType, page: params.page },
|
||||
{ root: true }
|
||||
);
|
||||
if (!chatList.length) {
|
||||
@@ -69,10 +67,7 @@ const actions = {
|
||||
} = await MessageApi.getPreviousMessages(data);
|
||||
commit(
|
||||
`conversationMetadata/${types.default.SET_CONVERSATION_METADATA}`,
|
||||
{
|
||||
id: data.conversationId,
|
||||
data: meta,
|
||||
}
|
||||
{ id: data.conversationId, data: meta }
|
||||
);
|
||||
commit(types.default.SET_PREVIOUS_CONVERSATIONS, {
|
||||
id: data.conversationId,
|
||||
@@ -140,14 +135,22 @@ const actions = {
|
||||
{ conversationId, status, snoozedUntil = null }
|
||||
) => {
|
||||
try {
|
||||
const response = await ConversationApi.toggleStatus({
|
||||
const {
|
||||
data: {
|
||||
payload: {
|
||||
current_status: updatedStatus,
|
||||
snoozed_until: updatedSnoozedUntil,
|
||||
} = {},
|
||||
} = {},
|
||||
} = await ConversationApi.toggleStatus({
|
||||
conversationId,
|
||||
status,
|
||||
snoozedUntil,
|
||||
});
|
||||
commit(types.default.RESOLVE_CONVERSATION, {
|
||||
commit(types.default.CHANGE_CONVERSATION_STATUS, {
|
||||
conversationId,
|
||||
status: response.data.payload.current_status,
|
||||
status: updatedStatus,
|
||||
snoozedUntil: updatedSnoozedUntil,
|
||||
});
|
||||
} catch (error) {
|
||||
// Handle error
|
||||
@@ -223,11 +226,7 @@ const actions = {
|
||||
data: { id, agent_last_seen_at: lastSeen },
|
||||
} = await ConversationApi.markMessageRead(data);
|
||||
setTimeout(
|
||||
() =>
|
||||
commit(types.default.MARK_MESSAGE_READ, {
|
||||
id,
|
||||
lastSeen,
|
||||
}),
|
||||
() => commit(types.default.MARK_MESSAGE_READ, { id, lastSeen }),
|
||||
4000
|
||||
);
|
||||
} catch (error) {
|
||||
|
||||
@@ -69,9 +69,13 @@ export const mutations = {
|
||||
Vue.set(chat.meta, 'team', team);
|
||||
},
|
||||
|
||||
[types.default.RESOLVE_CONVERSATION](_state, { conversationId, status }) {
|
||||
[types.default.CHANGE_CONVERSATION_STATUS](
|
||||
_state,
|
||||
{ conversationId, status, snoozedUntil }
|
||||
) {
|
||||
const conversation =
|
||||
getters.getConversationById(_state)(conversationId) || {};
|
||||
Vue.set(conversation, 'snoozed_until', snoozedUntil);
|
||||
Vue.set(conversation, 'status', status);
|
||||
},
|
||||
|
||||
|
||||
@@ -217,15 +217,24 @@ describe('#actions', () => {
|
||||
describe('#toggleStatus', () => {
|
||||
it('sends correct mutations if toggle status is successful', async () => {
|
||||
axios.post.mockResolvedValue({
|
||||
data: { payload: { conversation_id: 1, current_status: 'resolved' } },
|
||||
data: {
|
||||
payload: {
|
||||
conversation_id: 1,
|
||||
current_status: 'snoozed',
|
||||
snoozed_until: null,
|
||||
},
|
||||
},
|
||||
});
|
||||
await actions.toggleStatus(
|
||||
{ commit },
|
||||
{ conversationId: 1, status: 'resolved' }
|
||||
{ conversationId: 1, status: 'snoozed' }
|
||||
);
|
||||
expect(commit).toHaveBeenCalledTimes(1);
|
||||
expect(commit.mock.calls).toEqual([
|
||||
['RESOLVE_CONVERSATION', { conversationId: 1, status: 'resolved' }],
|
||||
[
|
||||
'CHANGE_CONVERSATION_STATUS',
|
||||
{ conversationId: 1, status: 'snoozed', snoozedUntil: null },
|
||||
],
|
||||
]);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -161,7 +161,7 @@ describe('#mutations', () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe('#RESOLVE_CONVERSATION', () => {
|
||||
describe('#CHANGE_CONVERSATION_STATUS', () => {
|
||||
it('updates the conversation status correctly', () => {
|
||||
const state = {
|
||||
allConversations: [
|
||||
@@ -173,7 +173,7 @@ describe('#mutations', () => {
|
||||
],
|
||||
};
|
||||
|
||||
mutations[types.RESOLVE_CONVERSATION](state, {
|
||||
mutations[types.CHANGE_CONVERSATION_STATUS](state, {
|
||||
conversationId: '1',
|
||||
status: 'resolved',
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user