fix:Avoid adding all new conversations when on a custom view (#8905)
This commit is contained in:
@@ -8,6 +8,7 @@ import {
|
|||||||
buildConversationList,
|
buildConversationList,
|
||||||
isOnMentionsView,
|
isOnMentionsView,
|
||||||
isOnUnattendedView,
|
isOnUnattendedView,
|
||||||
|
isOnFoldersView,
|
||||||
} from './helpers/actionHelpers';
|
} from './helpers/actionHelpers';
|
||||||
import messageReadActions from './actions/messageReadActions';
|
import messageReadActions from './actions/messageReadActions';
|
||||||
import messageTranslateActions from './actions/messageTranslateActions';
|
import messageTranslateActions from './actions/messageTranslateActions';
|
||||||
@@ -321,12 +322,12 @@ const actions = {
|
|||||||
inbox_id: inboxId,
|
inbox_id: inboxId,
|
||||||
meta: { sender },
|
meta: { sender },
|
||||||
} = conversation;
|
} = conversation;
|
||||||
|
|
||||||
const hasAppliedFilters = !!appliedFilters.length;
|
const hasAppliedFilters = !!appliedFilters.length;
|
||||||
const isMatchingInboxFilter =
|
const isMatchingInboxFilter =
|
||||||
!currentInbox || Number(currentInbox) === inboxId;
|
!currentInbox || Number(currentInbox) === inboxId;
|
||||||
if (
|
if (
|
||||||
!hasAppliedFilters &&
|
!hasAppliedFilters &&
|
||||||
|
!isOnFoldersView(rootState) &&
|
||||||
!isOnMentionsView(rootState) &&
|
!isOnMentionsView(rootState) &&
|
||||||
!isOnUnattendedView(rootState) &&
|
!isOnUnattendedView(rootState) &&
|
||||||
isMatchingInboxFilter
|
isMatchingInboxFilter
|
||||||
|
|||||||
@@ -30,6 +30,14 @@ export const isOnUnattendedView = ({ route: { name: routeName } }) => {
|
|||||||
return UNATTENDED_ROUTES.includes(routeName);
|
return UNATTENDED_ROUTES.includes(routeName);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const isOnFoldersView = ({ route: { name: routeName } }) => {
|
||||||
|
const FOLDER_ROUTES = [
|
||||||
|
'folder_conversations',
|
||||||
|
'conversations_through_folders',
|
||||||
|
];
|
||||||
|
return FOLDER_ROUTES.includes(routeName);
|
||||||
|
};
|
||||||
|
|
||||||
export const buildConversationList = (
|
export const buildConversationList = (
|
||||||
context,
|
context,
|
||||||
requestPayload,
|
requestPayload,
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { isOnMentionsView } from '../actionHelpers';
|
import { isOnMentionsView, isOnFoldersView } from '../actionHelpers';
|
||||||
|
|
||||||
describe('#isOnMentionsView', () => {
|
describe('#isOnMentionsView', () => {
|
||||||
it('return valid responses when passing the state', () => {
|
it('return valid responses when passing the state', () => {
|
||||||
@@ -10,3 +10,17 @@ describe('#isOnMentionsView', () => {
|
|||||||
);
|
);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe('#isOnFoldersView', () => {
|
||||||
|
it('return valid responses when passing the state', () => {
|
||||||
|
expect(isOnFoldersView({ route: { name: 'folder_conversations' } })).toBe(
|
||||||
|
true
|
||||||
|
);
|
||||||
|
expect(
|
||||||
|
isOnFoldersView({ route: { name: 'conversations_through_folders' } })
|
||||||
|
).toBe(true);
|
||||||
|
expect(isOnFoldersView({ route: { name: 'conversation_messages' } })).toBe(
|
||||||
|
false
|
||||||
|
);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|||||||
@@ -181,6 +181,26 @@ describe('#actions', () => {
|
|||||||
expect(dispatch.mock.calls).toEqual([]);
|
expect(dispatch.mock.calls).toEqual([]);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('doesnot send mutation if the view is conversation folders', () => {
|
||||||
|
const conversation = {
|
||||||
|
id: 1,
|
||||||
|
messages: [],
|
||||||
|
meta: { sender: { id: 1, name: 'john-doe' } },
|
||||||
|
inbox_id: 1,
|
||||||
|
};
|
||||||
|
actions.addConversation(
|
||||||
|
{
|
||||||
|
commit,
|
||||||
|
rootState: { route: { name: 'folder_conversations' } },
|
||||||
|
dispatch,
|
||||||
|
state: { currentInbox: 1, appliedFilters: [{ id: 'random-filter' }] },
|
||||||
|
},
|
||||||
|
conversation
|
||||||
|
);
|
||||||
|
expect(commit.mock.calls).toEqual([]);
|
||||||
|
expect(dispatch.mock.calls).toEqual([]);
|
||||||
|
});
|
||||||
|
|
||||||
it('sends correct mutations', () => {
|
it('sends correct mutations', () => {
|
||||||
const conversation = {
|
const conversation = {
|
||||||
id: 1,
|
id: 1,
|
||||||
|
|||||||
Reference in New Issue
Block a user