From 82e6935281cd40b445e8a734ee0fd9e7dbbcdf1a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20M=C3=BCllner?= Date: Fri, 8 Jul 2016 01:04:12 +0200 Subject: [PATCH] calendar: Move handling of ignored events to event source Ignoring events is currently implemented in the message list's event section, which means that the calendar does not consider ignored events when marking days with events. In order to fix this, move the handling of ignored events to the event source, which is shared between both components. https://bugzilla.gnome.org/show_bug.cgi?id=768538 --- js/ui/calendar.js | 38 +++++++++++++++++++++++--------------- 1 file changed, 23 insertions(+), 15 deletions(-) diff --git a/js/ui/calendar.js b/js/ui/calendar.js index 6e6c5f9b1..110ff7bf4 100644 --- a/js/ui/calendar.js +++ b/js/ui/calendar.js @@ -120,6 +120,9 @@ const EmptyEventSource = new Lang.Class({ destroy: function() { }, + ignoreEvent: function(event) { + }, + requestRange: function(begin, end) { }, @@ -184,6 +187,15 @@ const DBusEventSource = new Lang.Class({ this.isLoading = false; this.isDummy = false; + this._ignoredEvents = new Map(); + + let savedState = global.get_persistent_state('as', 'ignored_events'); + if (savedState) + savedState.deep_unpack().forEach(Lang.bind(this, + function(eventId) { + this._ignoredEvents.set(eventId, true); + })); + this._initialized = false; this._dbusProxy = new CalendarServer(); this._dbusProxy.init_async(GLib.PRIORITY_DEFAULT, null, Lang.bind(this, function(object, result) { @@ -298,6 +310,12 @@ const DBusEventSource = new Lang.Class({ } }, + ignoreEvent: function(event) { + this._ignoredEvents.set(event.id, true); + let savedState = new GLib.Variant('as', [...this._ignoredEvents.keys()]); + global.set_persistent_state('ignored_events', savedState); + }, + requestRange: function(begin, end) { if (!(_datesEqual(begin, this._lastRequestBegin) && _datesEqual(end, this._lastRequestEnd))) { this.isLoading = true; @@ -313,6 +331,10 @@ const DBusEventSource = new Lang.Class({ let result = []; for(let n = 0; n < this._events.length; n++) { let event = this._events[n]; + + if (this._ignoredEvents.has(event.id)) + continue; + if (_dateIntervalsOverlap (event.date, event.end, begin, end)) { result.push(event); } @@ -785,15 +807,6 @@ const EventsSection = new Lang.Class({ this._desktopSettings.connect('changed', Lang.bind(this, this._reloadEvents)); this._eventSource = new EmptyEventSource(); - this._ignoredEvents = new Map(); - - let savedState = global.get_persistent_state('as', 'ignored_events'); - if (savedState) - savedState.deep_unpack().forEach(Lang.bind(this, - function(eventId) { - this._ignoredEvents.set(eventId, true); - })); - this.parent(''); Shell.AppSystem.get_default().connect('installed-changed', @@ -802,9 +815,7 @@ const EventsSection = new Lang.Class({ }, _ignoreEvent: function(event) { - this._ignoredEvents.set(event.id, true); - let savedState = new GLib.Variant('as', [...this._ignoredEvents.keys()]); - global.set_persistent_state('ignored_events', savedState); + this._eventSource.ignoreEvent(event); }, setEventSource: function(eventSource) { @@ -850,9 +861,6 @@ const EventsSection = new Lang.Class({ for (let i = 0; i < events.length; i++) { let event = events[i]; - if (this._ignoredEvents.has(event.id)) - continue; - let message = new EventMessage(event, this._date); message.connect('close', Lang.bind(this, function() { this._ignoreEvent(event);