From e29d326da9d10fc6ddf271ae19b2395b9d5b83dd Mon Sep 17 00:00:00 2001 From: Emmanouil Konstantinidis Date: Fri, 22 May 2015 14:29:21 +0100 Subject: [PATCH 1/2] Start grouping notifications by repo --- src/js/components/notifications.js | 18 ++++++++++++++---- src/js/stores/notifications.js | 8 ++++++-- 2 files changed, 20 insertions(+), 6 deletions(-) diff --git a/src/js/components/notifications.js b/src/js/components/notifications.js index 4f9c58316..af050fe84 100644 --- a/src/js/components/notifications.js +++ b/src/js/components/notifications.js @@ -1,5 +1,6 @@ var React = require('react'); var Reflux = require('reflux'); +var _ = require('underscore'); var Loading = require('reloading'); var Actions = require('../actions/actions'); @@ -15,7 +16,7 @@ var Notifications = React.createClass({ getInitialState: function() { return { - notifications: [], + notifications: {}, loading: true }; }, @@ -31,10 +32,19 @@ var Notifications = React.createClass({ render: function () { var notifications; - if (this.state.notifications.length > 0) { + if (!_.isEmpty(this.state.notifications)) { notifications = ( - this.state.notifications.map(function(object, i){ - return ; + _.map(this.state.notifications, function(repo, i) { + return ( +
+

{i}

+ {repo.map(function(as, df) { + return ( + ) + ) + })} +
+ ); }) ); } else { diff --git a/src/js/stores/notifications.js b/src/js/stores/notifications.js index 1b1d0378c..eb3e0a391 100644 --- a/src/js/stores/notifications.js +++ b/src/js/stores/notifications.js @@ -40,8 +40,12 @@ var NotificationsStore = Reflux.createStore({ }, onGetNotificationsCompleted: function (notifications) { - this._notifications = notifications; - this.trigger(this._notifications); + var groupedNotifications = _.groupBy(notifications, function(object){ + return object.repository.name; + }); + + this._notifications = groupedNotifications; + this.trigger(groupedNotifications); }, onGetNotificationsFailed: function (error) { From e3c5a06d48f8a4be36bc9623739156e673dfcc45 Mon Sep 17 00:00:00 2001 From: Emmanouil Konstantinidis Date: Fri, 22 May 2015 19:45:51 +0100 Subject: [PATCH 2/2] Add key for notifications --- src/js/components/notifications.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/js/components/notifications.js b/src/js/components/notifications.js index af050fe84..ed8c6f125 100644 --- a/src/js/components/notifications.js +++ b/src/js/components/notifications.js @@ -40,8 +40,8 @@ var Notifications = React.createClass({

{i}

{repo.map(function(as, df) { return ( - ) - ) + + ); })} );