refactor: fold cache revalidation into the event dispatcher

This commit is contained in:
Shivam Mishra
2026-06-10 12:59:26 +05:30
parent 343b25842a
commit 3e65534e68
11 changed files with 136 additions and 184 deletions
@@ -1,7 +1,6 @@
import * as MutationHelpers from 'shared/helpers/vuex/mutationHelpers';
import * as types from '../mutation-types';
import AgentAPI from '../../api/agents';
import { createCacheRevalidateAction } from '../utils/cacheRevalidate';
export const state = {
records: [],
@@ -52,10 +51,6 @@ export const actions = {
commit(types.default.SET_AGENT_FETCHING_STATUS, false);
}
},
revalidate: createCacheRevalidateAction({
api: AgentAPI,
mutation: types.default.SET_AGENTS,
}),
create: async ({ commit }, agentInfo) => {
commit(types.default.SET_AGENT_CREATING_STATUS, true);
try {
@@ -2,7 +2,6 @@ import * as MutationHelpers from 'shared/helpers/vuex/mutationHelpers';
import types from '../mutation-types';
import AttributeAPI from '../../api/attributes';
import camelcaseKeys from 'camelcase-keys';
import { createCacheRevalidateAction } from '../utils/cacheRevalidate';
export const state = {
records: [],
@@ -55,10 +54,6 @@ export const actions = {
commit(types.SET_CUSTOM_ATTRIBUTE_UI_FLAG, { isFetching: false });
}
},
revalidate: createCacheRevalidateAction({
api: AttributeAPI,
mutation: types.SET_CUSTOM_ATTRIBUTE,
}),
create: async function createAttribute({ commit }, attributeObj) {
commit(types.SET_CUSTOM_ATTRIBUTE_UI_FLAG, { isCreating: true });
try {
@@ -1,5 +1,4 @@
import { throwErrorMessage } from 'dashboard/store/utils/api';
import { createCacheRevalidateAction } from 'dashboard/store/utils/cacheRevalidate';
import * as MutationHelpers from 'shared/helpers/vuex/mutationHelpers';
import * as types from '../mutation-types';
import CannedResponseAPI from '../../api/cannedResponse';
@@ -48,11 +47,6 @@ const actions = {
}
},
revalidateCannedResponses: createCacheRevalidateAction({
api: CannedResponseAPI,
mutation: types.default.SET_CANNED,
}),
createCannedResponse: async function createCannedResponse(
{ commit },
cannedObj
@@ -7,7 +7,6 @@ import FBChannel from '../../api/channel/fbChannel';
import TwilioChannel from '../../api/channel/twilioChannel';
import WhatsappChannel from '../../api/channel/whatsappChannel';
import { throwErrorMessage } from '../utils/api';
import { createCacheRevalidateAction } from '../utils/cacheRevalidate';
import AnalyticsHelper from '../../helper/AnalyticsHelper';
import camelcaseKeys from 'camelcase-keys';
import { ACCOUNT_EVENTS } from '../../helper/AnalyticsHelper/events';
@@ -190,11 +189,6 @@ const sendAnalyticsEvent = channelType => {
};
export const actions = {
revalidate: createCacheRevalidateAction({
api: InboxesAPI,
mutation: types.default.SET_INBOXES,
getData: response => response.data.payload,
}),
get: async ({ commit }) => {
commit(types.default.SET_INBOXES_UI_FLAG, { isFetching: true });
try {
@@ -3,7 +3,6 @@ import types from '../mutation-types';
import LabelsAPI from '../../api/labels';
import AnalyticsHelper from '../../helper/AnalyticsHelper';
import { LABEL_EVENTS } from '../../helper/AnalyticsHelper/events';
import { createCacheRevalidateAction } from '../utils/cacheRevalidate';
export const state = {
records: [],
@@ -33,12 +32,6 @@ export const getters = {
};
export const actions = {
revalidate: createCacheRevalidateAction({
api: LabelsAPI,
mutation: types.SET_LABELS,
getData: response => response.data.payload,
}),
get: async function getLabels({ commit }) {
commit(types.SET_LABEL_UI_FLAG, { isFetching: true });
try {
@@ -6,7 +6,6 @@ import {
DELETE_TEAM,
} from './types';
import TeamsAPI from '../../../api/teams';
import { createCacheRevalidateAction } from '../../utils/cacheRevalidate';
export const actions = {
create: async ({ commit }, teamInfo) => {
@@ -22,10 +21,6 @@ export const actions = {
commit(SET_TEAM_UI_FLAG, { isCreating: false });
}
},
revalidate: createCacheRevalidateAction({
api: TeamsAPI,
mutation: SET_TEAMS,
}),
get: async ({ commit }) => {
commit(SET_TEAM_UI_FLAG, { isFetching: true });
try {