From 64e56135c87a64deda6ab1a1a0877fb323d0cc9c Mon Sep 17 00:00:00 2001 From: Jan Schneider Date: Fri, 21 May 2010 19:33:14 +0200 Subject: [PATCH] Catch if events from ajax response are not for the current view anymore. --- kronolith/js/kronolith.js | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/kronolith/js/kronolith.js b/kronolith/js/kronolith.js index bad00cfae..e0828e8c5 100644 --- a/kronolith/js/kronolith.js +++ b/kronolith/js/kronolith.js @@ -1339,17 +1339,24 @@ KronolithCore = { var start = this.parseDate(r.response.sig.substr(0, 8)), end = this.parseDate(r.response.sig.substr(8, 8)), - dates = [start, end]; + dates = [start, end], + currentDates; this.storeCache(r.response.events || {}, r.response.cal, dates); // Check if this is the still the result of the most current request. - if (r.response.view != this.view || - r.response.sig != this.eventsLoading[r.response.cal]) { + if (r.response.sig != this.eventsLoading[r.response.cal]) { return; } delete this.eventsLoading[r.response.cal]; + // Check if the result is still for the current view. + currentDates = this.viewDates(this.date, this.view); + if (r.response.view != this.view || + !currentDates[0].equals(start)) { + return; + } + if (this.view != 'year' || !$H(this.eventsLoading).size()) { this.insertEvents(dates, this.view, r.response.cal); } -- 2.11.0