diff --git a/app/javascript/dashboard/store/modules/conversations/actions.js b/app/javascript/dashboard/store/modules/conversations/actions.js index 6bf5501ad..0a9d23c6b 100644 --- a/app/javascript/dashboard/store/modules/conversations/actions.js +++ b/app/javascript/dashboard/store/modules/conversations/actions.js @@ -8,6 +8,7 @@ import { buildConversationList, isOnMentionsView, isOnUnattendedView, + isOnFoldersView, } from './helpers/actionHelpers'; import messageReadActions from './actions/messageReadActions'; import messageTranslateActions from './actions/messageTranslateActions'; @@ -321,12 +322,12 @@ const actions = { inbox_id: inboxId, meta: { sender }, } = conversation; - const hasAppliedFilters = !!appliedFilters.length; const isMatchingInboxFilter = !currentInbox || Number(currentInbox) === inboxId; if ( !hasAppliedFilters && + !isOnFoldersView(rootState) && !isOnMentionsView(rootState) && !isOnUnattendedView(rootState) && isMatchingInboxFilter diff --git a/app/javascript/dashboard/store/modules/conversations/helpers/actionHelpers.js b/app/javascript/dashboard/store/modules/conversations/helpers/actionHelpers.js index 88ee39fd8..f1c594b26 100644 --- a/app/javascript/dashboard/store/modules/conversations/helpers/actionHelpers.js +++ b/app/javascript/dashboard/store/modules/conversations/helpers/actionHelpers.js @@ -30,6 +30,14 @@ export const isOnUnattendedView = ({ route: { name: 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 = ( context, requestPayload, diff --git a/app/javascript/dashboard/store/modules/conversations/helpers/specs/actionHelpers.spec.js b/app/javascript/dashboard/store/modules/conversations/helpers/specs/actionHelpers.spec.js index 32c6ff373..2dcf0b26b 100644 --- a/app/javascript/dashboard/store/modules/conversations/helpers/specs/actionHelpers.spec.js +++ b/app/javascript/dashboard/store/modules/conversations/helpers/specs/actionHelpers.spec.js @@ -1,4 +1,4 @@ -import { isOnMentionsView } from '../actionHelpers'; +import { isOnMentionsView, isOnFoldersView } from '../actionHelpers'; describe('#isOnMentionsView', () => { 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 + ); + }); +}); diff --git a/app/javascript/dashboard/store/modules/specs/conversations/actions.spec.js b/app/javascript/dashboard/store/modules/specs/conversations/actions.spec.js index 0b375a543..648ab2a46 100644 --- a/app/javascript/dashboard/store/modules/specs/conversations/actions.spec.js +++ b/app/javascript/dashboard/store/modules/specs/conversations/actions.spec.js @@ -181,6 +181,26 @@ describe('#actions', () => { 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', () => { const conversation = { id: 1,