calendar: Don't ever force reload
https://bugzilla.gnome.org/show_bug.cgi?id=720298
This commit is contained in:
parent
deb2f30b37
commit
9fce12d6b4
@ -329,25 +329,22 @@ const DBusEventSource = new Lang.Class({
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
if (this._curRequestBegin && this._curRequestEnd){
|
if (this._curRequestBegin && this._curRequestEnd){
|
||||||
let callFlags = Gio.DBusCallFlags.NO_AUTO_START;
|
|
||||||
if (forceReload)
|
|
||||||
callFlags = Gio.DBusCallFlags.NONE;
|
|
||||||
this._dbusProxy.GetEventsRemote(this._curRequestBegin.getTime() / 1000,
|
this._dbusProxy.GetEventsRemote(this._curRequestBegin.getTime() / 1000,
|
||||||
this._curRequestEnd.getTime() / 1000,
|
this._curRequestEnd.getTime() / 1000,
|
||||||
forceReload,
|
forceReload,
|
||||||
Lang.bind(this, this._onEventsReceived),
|
Lang.bind(this, this._onEventsReceived),
|
||||||
callFlags);
|
Gio.DBusCallFlags.NONE);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
requestRange: function(begin, end, forceReload) {
|
requestRange: function(begin, end) {
|
||||||
if (forceReload || !(_datesEqual(begin, this._lastRequestBegin) && _datesEqual(end, this._lastRequestEnd))) {
|
if (!(_datesEqual(begin, this._lastRequestBegin) && _datesEqual(end, this._lastRequestEnd))) {
|
||||||
this.isLoading = true;
|
this.isLoading = true;
|
||||||
this._lastRequestBegin = begin;
|
this._lastRequestBegin = begin;
|
||||||
this._lastRequestEnd = end;
|
this._lastRequestEnd = end;
|
||||||
this._curRequestBegin = begin;
|
this._curRequestBegin = begin;
|
||||||
this._curRequestEnd = end;
|
this._curRequestEnd = end;
|
||||||
this._loadEvents(forceReload);
|
this._loadEvents(false);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -419,21 +416,19 @@ const Calendar = new Lang.Class({
|
|||||||
setEventSource: function(eventSource) {
|
setEventSource: function(eventSource) {
|
||||||
this._eventSource = eventSource;
|
this._eventSource = eventSource;
|
||||||
this._eventSource.connect('changed', Lang.bind(this, function() {
|
this._eventSource.connect('changed', Lang.bind(this, function() {
|
||||||
this._update(false);
|
this._update();
|
||||||
}));
|
}));
|
||||||
this._update(true);
|
this._update();
|
||||||
},
|
},
|
||||||
|
|
||||||
// Sets the calendar to show a specific date
|
// Sets the calendar to show a specific date
|
||||||
setDate: function(date, forceReload) {
|
setDate: function(date) {
|
||||||
if (!_sameDay(date, this._selectedDate)) {
|
if (_sameDay(date, this._selectedDate))
|
||||||
this._selectedDate = date;
|
return;
|
||||||
this._update(forceReload);
|
|
||||||
this.emit('selected-date-changed', new Date(this._selectedDate));
|
this._selectedDate = date;
|
||||||
} else {
|
this._update();
|
||||||
if (forceReload)
|
this.emit('selected-date-changed', new Date(this._selectedDate));
|
||||||
this._update(forceReload);
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
|
|
||||||
_buildHeader: function() {
|
_buildHeader: function() {
|
||||||
@ -521,7 +516,7 @@ const Calendar = new Lang.Class({
|
|||||||
|
|
||||||
this._backButton.grab_key_focus();
|
this._backButton.grab_key_focus();
|
||||||
|
|
||||||
this.setDate(newDate, false);
|
this.setDate(newDate);
|
||||||
},
|
},
|
||||||
|
|
||||||
_onNextMonthButtonClicked: function() {
|
_onNextMonthButtonClicked: function() {
|
||||||
@ -545,16 +540,16 @@ const Calendar = new Lang.Class({
|
|||||||
|
|
||||||
this._forwardButton.grab_key_focus();
|
this._forwardButton.grab_key_focus();
|
||||||
|
|
||||||
this.setDate(newDate, false);
|
this.setDate(newDate);
|
||||||
},
|
},
|
||||||
|
|
||||||
_onSettingsChange: function() {
|
_onSettingsChange: function() {
|
||||||
this._useWeekdate = this._settings.get_boolean(SHOW_WEEKDATE_KEY);
|
this._useWeekdate = this._settings.get_boolean(SHOW_WEEKDATE_KEY);
|
||||||
this._buildHeader();
|
this._buildHeader();
|
||||||
this._update(false);
|
this._update();
|
||||||
},
|
},
|
||||||
|
|
||||||
_update: function(forceReload) {
|
_update: function() {
|
||||||
let now = new Date();
|
let now = new Date();
|
||||||
|
|
||||||
if (_sameYear(this._selectedDate, now))
|
if (_sameYear(this._selectedDate, now))
|
||||||
@ -614,7 +609,7 @@ const Calendar = new Lang.Class({
|
|||||||
this._shouldDateGrabFocus = true;
|
this._shouldDateGrabFocus = true;
|
||||||
|
|
||||||
let newlySelectedDate = new Date(iterStr);
|
let newlySelectedDate = new Date(iterStr);
|
||||||
this.setDate(newlySelectedDate, false);
|
this.setDate(newlySelectedDate);
|
||||||
|
|
||||||
this._shouldDateGrabFocus = false;
|
this._shouldDateGrabFocus = false;
|
||||||
}));
|
}));
|
||||||
@ -671,7 +666,7 @@ const Calendar = new Lang.Class({
|
|||||||
}
|
}
|
||||||
// Signal to the event source that we are interested in events
|
// Signal to the event source that we are interested in events
|
||||||
// only from this date range
|
// only from this date range
|
||||||
this._eventSource.requestRange(beginDate, iter, forceReload);
|
this._eventSource.requestRange(beginDate, iter);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -113,22 +113,7 @@ const DateMenuButton = new Lang.Class({
|
|||||||
this.menu.connect('open-state-changed', Lang.bind(this, function(menu, isOpen) {
|
this.menu.connect('open-state-changed', Lang.bind(this, function(menu, isOpen) {
|
||||||
if (isOpen) {
|
if (isOpen) {
|
||||||
let now = new Date();
|
let now = new Date();
|
||||||
/* Passing true to setDate() forces events to be reloaded. We
|
this._calendar.setDate(now);
|
||||||
* want this behavior, because
|
|
||||||
*
|
|
||||||
* o It will cause activation of the calendar server which is
|
|
||||||
* useful if it has crashed
|
|
||||||
*
|
|
||||||
* o It will cause the calendar server to reload events which
|
|
||||||
* is useful if dynamic updates are not supported or not
|
|
||||||
* properly working
|
|
||||||
*
|
|
||||||
* Since this only happens when the menu is opened, the cost
|
|
||||||
* isn't very big.
|
|
||||||
*/
|
|
||||||
this._calendar.setDate(now, true);
|
|
||||||
// No need to update this._eventList as ::selected-date-changed
|
|
||||||
// signal will fire
|
|
||||||
}
|
}
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user