[gnome-shell/wip/fmuellner/notification-redux+sass: 139/207] calendar: Save a bit of work in events list



commit b4bcac038068c73e43ff2ff732f90af21e573f37
Author: Florian Müllner <fmuellner gnome org>
Date:   Fri Feb 13 12:15:55 2015 +0100

    calendar: Save a bit of work in events list

 js/ui/calendar.js |   23 ++++++++++++-----------
 1 files changed, 12 insertions(+), 11 deletions(-)
---
diff --git a/js/ui/calendar.js b/js/ui/calendar.js
index 86e2fe8..239fe35 100644
--- a/js/ui/calendar.js
+++ b/js/ui/calendar.js
@@ -984,13 +984,13 @@ const MessageListSection = new Lang.Class({
         return this._list.get_n_children() == 0;
     },
 
-    _shouldShowForDate: function() {
+    _isToday: function() {
         let today = new Date();
         return _sameDay(this._date, today);
     },
 
     _sync: function() {
-        this.actor.visible = !this.isEmpty() && this._shouldShowForDate();
+        this.actor.visible = !this.isEmpty() && this._isToday();
     }
 });
 
@@ -1362,15 +1362,14 @@ const EventsSection = new Lang.Class({
         if (this._eventSource.isLoading)
             return;
 
+        this._reloading = true;
+
         this.clear();
 
         let periodBegin = _getBeginningOfDay(this._date);
         let periodEnd = _getEndOfDay(this._date);
         let events = this._eventSource.getEvents(periodBegin, periodEnd);
 
-        if (events.length == 0)
-            return;
-
         let clockFormat = this._desktopSettings.get_string(CLOCK_FORMAT_KEY);
         for (let i = 0; i < events.length; i++) {
             let event = events[i];
@@ -1390,8 +1389,11 @@ const EventsSection = new Lang.Class({
                     title = title + ELLIPSIS_CHAR;
             }
             let eventEntry = new MessageListEntry(title, event.summary);
-            this._list.add(eventEntry.actor);
+            this.addMessage(eventEntry, false);
         }
+
+        this._reloading = false;
+        this._sync();
     },
 
     _appInstalledChanged: function() {
@@ -1427,13 +1429,12 @@ const EventsSection = new Lang.Class({
     },
 
     _sync: function() {
-        this.actor.visible = !this.isEmpty() || !_sameDay(this._date, new Date());
+        if (this._reloading)
+            return;
+
+        this.actor.visible = !this.isEmpty() || !this._isToday();
         this._closeButton.visible = !this.isEmpty();
         this._updateTitle();
-    },
-
-    _shouldShowForDate: function() {
-        return true;
     }
 });
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]