calendar: Update events on changes
We track messages so that we can account for just added and removed events instead of having to rebuild the entire list, however it's also possible that the time or summary of an existing event changed. Account for that by updating existing messages in-place. https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/1192
This commit is contained in:
parent
c5e5bb0be1
commit
8d79f6f4c8
@ -701,12 +701,11 @@ var Calendar = GObject.registerClass({
|
|||||||
var EventMessage = GObject.registerClass(
|
var EventMessage = GObject.registerClass(
|
||||||
class EventMessage extends MessageList.Message {
|
class EventMessage extends MessageList.Message {
|
||||||
_init(event, date) {
|
_init(event, date) {
|
||||||
super._init('', event.summary);
|
super._init('', '');
|
||||||
|
|
||||||
this._event = event;
|
|
||||||
this._date = date;
|
this._date = date;
|
||||||
|
|
||||||
this.setTitle(this._formatEventTime());
|
this.update(event);
|
||||||
|
|
||||||
this._icon = new St.Icon({ icon_name: 'x-office-calendar-symbolic' });
|
this._icon = new St.Icon({ icon_name: 'x-office-calendar-symbolic' });
|
||||||
this.setIcon(this._icon);
|
this.setIcon(this._icon);
|
||||||
@ -718,6 +717,13 @@ class EventMessage extends MessageList.Message {
|
|||||||
super.vfunc_style_changed();
|
super.vfunc_style_changed();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
update(event) {
|
||||||
|
this._event = event;
|
||||||
|
|
||||||
|
this.setTitle(this._formatEventTime());
|
||||||
|
this.setBody(event.summary);
|
||||||
|
}
|
||||||
|
|
||||||
_formatEventTime() {
|
_formatEventTime() {
|
||||||
let periodBegin = _getBeginningOfDay(this._date);
|
let periodBegin = _getBeginningOfDay(this._date);
|
||||||
let periodEnd = _getEndOfDay(this._date);
|
let periodEnd = _getEndOfDay(this._date);
|
||||||
@ -901,6 +907,7 @@ class EventsSection extends MessageList.MessageListSection {
|
|||||||
this._messageById.set(event.id, message);
|
this._messageById.set(event.id, message);
|
||||||
this.addMessage(message, false);
|
this.addMessage(message, false);
|
||||||
} else {
|
} else {
|
||||||
|
message.update(event);
|
||||||
this.moveMessage(message, i, false);
|
this.moveMessage(message, i, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user