[Vtigercrm-developers] Problem after using setInterval in Calendar...
Alan Lord
alanslists at gmail.com
Wed May 25 10:24:16 GMT 2022
Consider this.
You have several users logged into their vtiger 7 system and they are
regular users of the Shared Calendar. One of my customers wanted the
calendar to "auto-refresh" so that if another user added an event (all
shared, public users), within a few seconds other users' calendars would
redraw and the new item would appear like magic!
So I added a refreshCalendarFeed method to the Calendar class that does
exactly this every 10 seconds. And it works quite nicely.
> refreshCalendarFeed : function() {
> var thisInstance = this;
> if(!thisInstance.intervalId) {
> thisInstance.intervalId = setInterval( () => thisInstance.renderEvents(), 10000);
> }
> },
Most of the time...
But, if you have had your calendar view open for a few minutes or
longer, then click the next or previous month navigation buttons, for
some reason I cannot work out at all, the browser then sends duplicate
requests for EVERY previous refresh... Even though they are all the same
(batch mode feed request).
For example, say there had been 20 refreshes over the past few minutes
on your screen, then you want to look at next month. Click the button
and the code sends 20 POST requests asking for a batch feed of the
calendar all with the same parameters etc. This causes everything to
slow down - obviously - so the calendar doesn't reload for many seconds
as it is dealing with 20 simultaneous Ajax requests...
Has anyone got any ideas what's going on here?
Cheers
Al
More information about the vtigercrm-developers
mailing list