From 1bece82a3a547d2c2d1fbe3a4b18c3cd88e4e6cf Mon Sep 17 00:00:00 2001 From: mossroy Date: Sun, 25 Sep 2016 16:53:06 +0200 Subject: [PATCH 1/2] Bug 1258193 - Check undefined variables to workaround disappearing calendar events I had errors in the console because of these variables being undefined. Adding these checks solved the issue of events disappearing after a restart. I did not investigate more on the reasons behind that. --- apps/calendar/js/day_observer.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/apps/calendar/js/day_observer.js b/apps/calendar/js/day_observer.js index 73f1caf8512b..082d1032a1e2 100644 --- a/apps/calendar/js/day_observer.js +++ b/apps/calendar/js/day_observer.js @@ -138,7 +138,7 @@ exports.removeAllListeners = function() { // cache data and show the event details faster on the most common cases exports.findAssociated = function(busytimeId) { return queryBusytime(busytimeId).then(busytime => { - return queryEvent(busytime.eventId).then(event => { + if (busytime) return queryEvent(busytime.eventId).then(event => { return { busytime: busytime, event: event @@ -172,7 +172,7 @@ function cacheBusytime(busy) { } busytimes.set(_id, busy); - eventsToBusytimes.get(eventId).push(_id); + if (eventsToBusytimes.get(eventId)) eventsToBusytimes.get(eventId).push(_id); registerBusytimeChange(_id); } @@ -262,7 +262,7 @@ function sortedInsert(group, busy) { }); var event = events.get(busy.eventId); var calendarStore = core.storeFactory.get('Calendar'); - group.splice(index, 0, { + if (event) group.splice(index, 0, { event: event, busytime: busy, color: calendarStore.getColorByCalendarId(event.calendarId) From c678aad75398705f040e239ff4f10ec9bd923187 Mon Sep 17 00:00:00 2001 From: mossroy Date: Wed, 5 Oct 2016 14:40:37 +0200 Subject: [PATCH 2/2] Cleaner way to check for undefined --- apps/calendar/js/day_observer.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/apps/calendar/js/day_observer.js b/apps/calendar/js/day_observer.js index 082d1032a1e2..737dd26aa959 100644 --- a/apps/calendar/js/day_observer.js +++ b/apps/calendar/js/day_observer.js @@ -138,7 +138,7 @@ exports.removeAllListeners = function() { // cache data and show the event details faster on the most common cases exports.findAssociated = function(busytimeId) { return queryBusytime(busytimeId).then(busytime => { - if (busytime) return queryEvent(busytime.eventId).then(event => { + if (typeof busytime !== 'undefined') return queryEvent(busytime.eventId).then(event => { return { busytime: busytime, event: event @@ -172,7 +172,7 @@ function cacheBusytime(busy) { } busytimes.set(_id, busy); - if (eventsToBusytimes.get(eventId)) eventsToBusytimes.get(eventId).push(_id); + if (typeof eventsToBusytimes.get(eventId) !== 'undefined') eventsToBusytimes.get(eventId).push(_id); registerBusytimeChange(_id); } @@ -262,7 +262,7 @@ function sortedInsert(group, busy) { }); var event = events.get(busy.eventId); var calendarStore = core.storeFactory.get('Calendar'); - if (event) group.splice(index, 0, { + if (typeof event !== 'undefined') group.splice(index, 0, { event: event, busytime: busy, color: calendarStore.getColorByCalendarId(event.calendarId)