2020-02-26 15:45:01 +00:00
|
|
|
import Vue from 'vue';
|
|
|
|
import * as types from '../mutation-types';
|
|
|
|
|
|
|
|
const state = {
|
|
|
|
currentPage: {
|
|
|
|
me: 0,
|
|
|
|
unassigned: 0,
|
|
|
|
all: 0,
|
2021-11-18 13:45:02 +00:00
|
|
|
appliedFilters: 0,
|
2020-02-26 15:45:01 +00:00
|
|
|
},
|
|
|
|
hasEndReached: {
|
|
|
|
me: false,
|
|
|
|
unassigned: false,
|
|
|
|
all: false,
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
|
|
|
export const getters = {
|
|
|
|
getHasEndReached: $state => filter => {
|
|
|
|
return $state.hasEndReached[filter];
|
|
|
|
},
|
2021-04-22 08:28:04 +00:00
|
|
|
getCurrentPageFilter: $state => filter => {
|
2020-02-26 15:45:01 +00:00
|
|
|
return $state.currentPage[filter];
|
|
|
|
},
|
2021-04-22 08:28:04 +00:00
|
|
|
getCurrentPage: $state => {
|
|
|
|
return $state.currentPage;
|
|
|
|
},
|
2020-02-26 15:45:01 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
export const actions = {
|
|
|
|
setCurrentPage({ commit }, { filter, page }) {
|
|
|
|
commit(types.default.SET_CURRENT_PAGE, { filter, page });
|
|
|
|
},
|
|
|
|
setEndReached({ commit }, { filter }) {
|
|
|
|
commit(types.default.SET_CONVERSATION_END_REACHED, { filter });
|
|
|
|
},
|
|
|
|
reset({ commit }) {
|
|
|
|
commit(types.default.CLEAR_CONVERSATION_PAGE);
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
|
|
|
export const mutations = {
|
|
|
|
[types.default.SET_CURRENT_PAGE]: ($state, { filter, page }) => {
|
|
|
|
Vue.set($state.currentPage, filter, page);
|
|
|
|
},
|
|
|
|
[types.default.SET_CONVERSATION_END_REACHED]: ($state, { filter }) => {
|
|
|
|
if (filter === 'all') {
|
|
|
|
Vue.set($state.hasEndReached, 'unassigned', true);
|
|
|
|
Vue.set($state.hasEndReached, 'me', true);
|
|
|
|
}
|
|
|
|
Vue.set($state.hasEndReached, filter, true);
|
|
|
|
},
|
|
|
|
[types.default.CLEAR_CONVERSATION_PAGE]: $state => {
|
|
|
|
$state.currentPage = {
|
|
|
|
me: 0,
|
|
|
|
unassigned: 0,
|
|
|
|
all: 0,
|
2021-11-18 13:45:02 +00:00
|
|
|
appliedFilters: 0,
|
2020-02-26 15:45:01 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
$state.hasEndReached = {
|
|
|
|
me: false,
|
|
|
|
unassigned: false,
|
|
|
|
all: false,
|
2021-11-18 13:45:02 +00:00
|
|
|
appliedFilters: false,
|
2020-02-26 15:45:01 +00:00
|
|
|
};
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
|
|
|
export default {
|
|
|
|
namespaced: true,
|
|
|
|
state,
|
|
|
|
getters,
|
|
|
|
actions,
|
|
|
|
mutations,
|
|
|
|
};
|