From d32a69a65706a612fc92a69344335d0053654e47 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Mon, 23 May 2022 18:27:05 +0200 Subject: [PATCH] prevent loading users calendar multiple times when adding multiple users --- .../Resources/public/vuejs/Calendar/store/actions.js | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/Bundle/ChillCalendarBundle/Resources/public/vuejs/Calendar/store/actions.js b/src/Bundle/ChillCalendarBundle/Resources/public/vuejs/Calendar/store/actions.js index 1e1faab19..00e78143b 100644 --- a/src/Bundle/ChillCalendarBundle/Resources/public/vuejs/Calendar/store/actions.js +++ b/src/Bundle/ChillCalendarBundle/Resources/public/vuejs/Calendar/store/actions.js @@ -10,6 +10,8 @@ import { } from './../api'; import {datetimeToISO} from 'ChillMainAssets/chill/js/date'; +const fetchings = new Set(); + export default { setCurrentDatesView({ commit, dispatch }, {start, end}) { commit('setCurrentDatesView', {start, end}); @@ -23,6 +25,15 @@ export default { let promises = []; for (const uid of state.currentView.users.keys()) { + let unique = `${uid}, ${state.currentView.start.toISOString()}, ${state.currentView.end.toISOString()}`; + + if (fetchings.has(unique)) { + console.log('prevent from fetching for a user', unique); + continue; + } + + fetchings.add(unique); + promises.push( dispatch( 'fetchCalendarRangeForUser',