From eb3f92d81e1d72b367ad9a810ee0013c81f84ac2 Mon Sep 17 00:00:00 2001 From: Emmanouil Konstantinidis Date: Sun, 24 May 2015 16:29:06 +0100 Subject: [PATCH 1/5] Change group function to string --- src/js/stores/notifications.js | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/js/stores/notifications.js b/src/js/stores/notifications.js index eb3e0a391..af526ddd4 100644 --- a/src/js/stores/notifications.js +++ b/src/js/stores/notifications.js @@ -40,10 +40,7 @@ var NotificationsStore = Reflux.createStore({ }, onGetNotificationsCompleted: function (notifications) { - var groupedNotifications = _.groupBy(notifications, function(object){ - return object.repository.name; - }); - + var groupedNotifications = _.groupBy(notifications, 'repository.name'); this._notifications = groupedNotifications; this.trigger(groupedNotifications); }, From e992cd943a0c20d1e87894c681c5efc1dd59ef7e Mon Sep 17 00:00:00 2001 From: Emmanouil Konstantinidis Date: Sun, 24 May 2015 16:37:41 +0100 Subject: [PATCH 2/5] Initial state of notifications - null --- src/js/components/notifications.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/js/components/notifications.js b/src/js/components/notifications.js index c6ee2289b..a47e4cbce 100644 --- a/src/js/components/notifications.js +++ b/src/js/components/notifications.js @@ -18,7 +18,7 @@ var Notifications = React.createClass({ getInitialState: function() { return { - notifications: {}, + notifications: null, loading: true }; }, From 7bebab2560dec021d9ca30c7af6dcb0af37886b0 Mon Sep 17 00:00:00 2001 From: Emmanouil Konstantinidis Date: Sun, 24 May 2015 17:08:11 +0100 Subject: [PATCH 3/5] Create arrays of grouped notifications --- src/js/stores/notifications.js | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/js/stores/notifications.js b/src/js/stores/notifications.js index af526ddd4..b2fddcbdd 100644 --- a/src/js/stores/notifications.js +++ b/src/js/stores/notifications.js @@ -40,9 +40,17 @@ var NotificationsStore = Reflux.createStore({ }, onGetNotificationsCompleted: function (notifications) { - var groupedNotifications = _.groupBy(notifications, 'repository.name'); - this._notifications = groupedNotifications; - this.trigger(groupedNotifications); + var groupedNotifications = _.groupBy(notifications, function(object){ + return object.repository.full_name; + }); + + var array= []; + _.map(groupedNotifications, function(obj, i) { + array.push(obj); + }); + + this._notifications = array; + this.trigger(array); }, onGetNotificationsFailed: function (error) { From a31ede978815b24e0d9473abeb7a41d052589378 Mon Sep 17 00:00:00 2001 From: Emmanouil Konstantinidis Date: Sun, 24 May 2015 19:37:36 +0100 Subject: [PATCH 4/5] Render without using underscore --- src/js/components/notifications.js | 18 +++++++++--------- src/js/components/repository.js | 14 +++++--------- src/js/stores/notifications.js | 4 ++-- 3 files changed, 16 insertions(+), 20 deletions(-) diff --git a/src/js/components/notifications.js b/src/js/components/notifications.js index a47e4cbce..6e7a9173e 100644 --- a/src/js/components/notifications.js +++ b/src/js/components/notifications.js @@ -18,7 +18,7 @@ var Notifications = React.createClass({ getInitialState: function() { return { - notifications: null, + notifications: [], loading: true }; }, @@ -36,14 +36,7 @@ var Notifications = React.createClass({ var wrapperClass = 'container-fluid main-container notifications'; var self = this; - if (!_.isEmpty(this.state.notifications)) { - notifications = ( - _.map(this.state.notifications, function(repo, i) { - var repoFullName = repo[0].repository.full_name; - return ; - }) - ); - } else { + if (_.isEmpty(this.state.notifications)) { wrapperClass += ' all-read'; notifications = (
@@ -52,6 +45,13 @@ var Notifications = React.createClass({
); + } else { + this.state.notifications.map(function(obj, i) { + var repoFullName = obj[0].repository.full_name; + notifications = ( + + ); + }); } return ( diff --git a/src/js/components/repository.js b/src/js/components/repository.js index d0b697a8a..5d84d07c2 100644 --- a/src/js/components/repository.js +++ b/src/js/components/repository.js @@ -17,21 +17,17 @@ var Repository = React.createClass({ }, render: function () { - var notifications = ( - _.map(this.props.repo, function(notification, i) { - return ( - - ); - }) - ); - return (
{this.props.repoName}
- {notifications} + + {this.props.repo.map(function(obj, i) { + return ; + })} +
); } diff --git a/src/js/stores/notifications.js b/src/js/stores/notifications.js index b2fddcbdd..b19c3ea83 100644 --- a/src/js/stores/notifications.js +++ b/src/js/stores/notifications.js @@ -10,7 +10,7 @@ var NotificationsStore = Reflux.createStore({ listenables: Actions, init: function () { - this._notifications = undefined; + this._notifications = []; }, updateTrayIcon: function (notifications) { @@ -50,7 +50,7 @@ var NotificationsStore = Reflux.createStore({ }); this._notifications = array; - this.trigger(array); + this.trigger(this._notifications); }, onGetNotificationsFailed: function (error) { From cc58e04aeeb67c0cbe16a447037d3c5a70c59c31 Mon Sep 17 00:00:00 2001 From: Emmanouil Konstantinidis Date: Sun, 24 May 2015 21:13:13 +0100 Subject: [PATCH 5/5] Show all repos --- src/js/components/notifications.js | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/js/components/notifications.js b/src/js/components/notifications.js index 6e7a9173e..f422942b5 100644 --- a/src/js/components/notifications.js +++ b/src/js/components/notifications.js @@ -46,12 +46,13 @@ var Notifications = React.createClass({ ); } else { - this.state.notifications.map(function(obj, i) { - var repoFullName = obj[0].repository.full_name; - notifications = ( - - ); - }); + notifications = ( + this.state.notifications.map(function(obj, i) { + console.log(obj); + var repoFullName = obj[0].repository.full_name; + return ; + }) + ); } return (