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
This commit is contained in:
parent
61070e6ec0
commit
82e6935281
@ -120,6 +120,9 @@ const EmptyEventSource = new Lang.Class({
|
|||||||
destroy: function() {
|
destroy: function() {
|
||||||
},
|
},
|
||||||
|
|
||||||
|
ignoreEvent: function(event) {
|
||||||
|
},
|
||||||
|
|
||||||
requestRange: function(begin, end) {
|
requestRange: function(begin, end) {
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -184,6 +187,15 @@ const DBusEventSource = new Lang.Class({
|
|||||||
this.isLoading = false;
|
this.isLoading = false;
|
||||||
this.isDummy = 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._initialized = false;
|
||||||
this._dbusProxy = new CalendarServer();
|
this._dbusProxy = new CalendarServer();
|
||||||
this._dbusProxy.init_async(GLib.PRIORITY_DEFAULT, null, Lang.bind(this, function(object, result) {
|
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) {
|
requestRange: function(begin, end) {
|
||||||
if (!(_datesEqual(begin, this._lastRequestBegin) && _datesEqual(end, this._lastRequestEnd))) {
|
if (!(_datesEqual(begin, this._lastRequestBegin) && _datesEqual(end, this._lastRequestEnd))) {
|
||||||
this.isLoading = true;
|
this.isLoading = true;
|
||||||
@ -313,6 +331,10 @@ const DBusEventSource = new Lang.Class({
|
|||||||
let result = [];
|
let result = [];
|
||||||
for(let n = 0; n < this._events.length; n++) {
|
for(let n = 0; n < this._events.length; n++) {
|
||||||
let event = this._events[n];
|
let event = this._events[n];
|
||||||
|
|
||||||
|
if (this._ignoredEvents.has(event.id))
|
||||||
|
continue;
|
||||||
|
|
||||||
if (_dateIntervalsOverlap (event.date, event.end, begin, end)) {
|
if (_dateIntervalsOverlap (event.date, event.end, begin, end)) {
|
||||||
result.push(event);
|
result.push(event);
|
||||||
}
|
}
|
||||||
@ -785,15 +807,6 @@ const EventsSection = new Lang.Class({
|
|||||||
this._desktopSettings.connect('changed', Lang.bind(this, this._reloadEvents));
|
this._desktopSettings.connect('changed', Lang.bind(this, this._reloadEvents));
|
||||||
this._eventSource = new EmptyEventSource();
|
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('');
|
this.parent('');
|
||||||
|
|
||||||
Shell.AppSystem.get_default().connect('installed-changed',
|
Shell.AppSystem.get_default().connect('installed-changed',
|
||||||
@ -802,9 +815,7 @@ const EventsSection = new Lang.Class({
|
|||||||
},
|
},
|
||||||
|
|
||||||
_ignoreEvent: function(event) {
|
_ignoreEvent: function(event) {
|
||||||
this._ignoredEvents.set(event.id, true);
|
this._eventSource.ignoreEvent(event);
|
||||||
let savedState = new GLib.Variant('as', [...this._ignoredEvents.keys()]);
|
|
||||||
global.set_persistent_state('ignored_events', savedState);
|
|
||||||
},
|
},
|
||||||
|
|
||||||
setEventSource: function(eventSource) {
|
setEventSource: function(eventSource) {
|
||||||
@ -850,9 +861,6 @@ const EventsSection = new Lang.Class({
|
|||||||
for (let i = 0; i < events.length; i++) {
|
for (let i = 0; i < events.length; i++) {
|
||||||
let event = events[i];
|
let event = events[i];
|
||||||
|
|
||||||
if (this._ignoredEvents.has(event.id))
|
|
||||||
continue;
|
|
||||||
|
|
||||||
let message = new EventMessage(event, this._date);
|
let message = new EventMessage(event, this._date);
|
||||||
message.connect('close', Lang.bind(this, function() {
|
message.connect('close', Lang.bind(this, function() {
|
||||||
this._ignoreEvent(event);
|
this._ignoreEvent(event);
|
||||||
|
Loading…
Reference in New Issue
Block a user