Converts the canned-response and agent API clients to CacheEnabledApiClient subclasses and wires revalidate actions into the corresponding Vuex modules, so settings pages and pickers stop fetching the same lists on every visit. The canned-response search box continues to bypass the cache and hit the network directly, so server-side ordering stays authoritative. Also fixes a pre-existing gap in teams/revalidate: SET_TEAMS merges into a record dict by id and never removes missing entries, so a team deleted server-side would survive a reconnect-driven revalidate. Now matches the get action by emitting CLEAR_TEAMS first. Each affected spec clears its IDB store before every case, since the preflight-throws-on-axios-reject pattern they relied on is going away in the next commit.
34 lines
757 B
JavaScript
34 lines
757 B
JavaScript
/* global axios */
|
|
|
|
import CacheEnabledApiClient from './CacheEnabledApiClient';
|
|
|
|
class CannedResponse extends CacheEnabledApiClient {
|
|
constructor() {
|
|
super('canned_responses', { accountScoped: true });
|
|
}
|
|
|
|
// eslint-disable-next-line class-methods-use-this
|
|
get cacheModelName() {
|
|
return 'canned_response';
|
|
}
|
|
|
|
// eslint-disable-next-line class-methods-use-this
|
|
extractDataFromResponse(response) {
|
|
return response.data;
|
|
}
|
|
|
|
// eslint-disable-next-line class-methods-use-this
|
|
marshallData(dataToParse) {
|
|
return { data: dataToParse };
|
|
}
|
|
|
|
get({ searchKey } = {}) {
|
|
if (searchKey) {
|
|
return axios.get(`${this.url}?search=${searchKey}`);
|
|
}
|
|
return super.get(true);
|
|
}
|
|
}
|
|
|
|
export default new CannedResponse();
|