feat: skip meta fetch if data is atleast 10s old

This commit is contained in:
Shivam Mishra
2024-11-28 23:18:24 +05:30
parent 94c918e468
commit df82f2f30b
@@ -5,6 +5,7 @@ const state = {
mineCount: 0,
unAssignedCount: 0,
allCount: 0,
updatedOn: null,
};
export const getters = {
@@ -13,6 +14,14 @@ export const getters = {
export const actions = {
get: async ({ commit }, params) => {
const currentTime = new Date();
const lastUpdatedTime = new Date(state.updatedOn);
if (currentTime - lastUpdatedTime < 10000) {
console.warn('Skipping conversation meta fetch');
return;
}
try {
const response = await ConversationApi.meta(params);
const {
@@ -40,6 +49,7 @@ export const mutations = {
$state.mineCount = mineCount;
$state.allCount = allCount;
$state.unAssignedCount = unAssignedCount;
$state.updatedOn = new Date();
},
};