calendar: Permanently hide dismissed events
Currently dismissed events will simply reappear when browsing back and forth between dates, which is clearly broken. Instead, hide events that have been dismissed permanently. For now, we simply store a list of ignored IDs ourselves, until we get API in evolution-data-server to reliably store custom per-event properties. https://bugzilla.gnome.org/show_bug.cgi?id=744927
This commit is contained in:
parent
8aeebbbf78
commit
777616d8b0
@ -242,7 +242,8 @@ const URLHighlighter = new Lang.Class({
|
||||
const CalendarEvent = new Lang.Class({
|
||||
Name: 'CalendarEvent',
|
||||
|
||||
_init: function(date, end, summary, allDay) {
|
||||
_init: function(id, date, end, summary, allDay) {
|
||||
this.id = id;
|
||||
this.date = date;
|
||||
this.end = end;
|
||||
this.summary = summary;
|
||||
@ -414,9 +415,10 @@ const DBusEventSource = new Lang.Class({
|
||||
let a = appointments[n];
|
||||
let date = new Date(a[4] * 1000);
|
||||
let end = new Date(a[5] * 1000);
|
||||
let id = a[0];
|
||||
let summary = a[1];
|
||||
let allDay = a[3];
|
||||
let event = new CalendarEvent(date, end, summary, allDay);
|
||||
let event = new CalendarEvent(id, date, end, summary, allDay);
|
||||
newEvents.push(event);
|
||||
}
|
||||
newEvents.sort(function(event1, event2) {
|
||||
@ -1477,6 +1479,15 @@ 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',
|
||||
@ -1484,6 +1495,12 @@ const EventsSection = new Lang.Class({
|
||||
this._appInstalledChanged();
|
||||
},
|
||||
|
||||
_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);
|
||||
},
|
||||
|
||||
setEventSource: function(eventSource) {
|
||||
this._eventSource = eventSource;
|
||||
this._eventSource.connect('changed', Lang.bind(this, this._reloadEvents));
|
||||
@ -1526,7 +1543,15 @@ const EventsSection = new Lang.Class({
|
||||
|
||||
for (let i = 0; i < events.length; i++) {
|
||||
let event = events[i];
|
||||
this.addMessage(new EventMessage(event, this._date), false);
|
||||
|
||||
if (this._ignoredEvents.has(event.id))
|
||||
continue;
|
||||
|
||||
let message = new EventMessage(event, this._date);
|
||||
message.connect('close', Lang.bind(this, function() {
|
||||
this._ignoreEvent(event);
|
||||
}));
|
||||
this.addMessage(message, false);
|
||||
}
|
||||
|
||||
this._reloading = false;
|
||||
|
Loading…
Reference in New Issue
Block a user