Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 10 additions & 9 deletions src/js/components/notifications.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ var Notifications = React.createClass({

getInitialState: function() {
return {
notifications: {},
notifications: [],
loading: true
};
},
Expand All @@ -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 <Repository repo={repo} repoName={repoFullName} key={i} />;
})
);
} else {
if (_.isEmpty(this.state.notifications)) {
wrapperClass += ' all-read';
notifications = (
<div>
Expand All @@ -52,6 +45,14 @@ var Notifications = React.createClass({
<img className='img-responsive emoji' src='images/rocket.png' />
</div>
);
} else {
notifications = (
this.state.notifications.map(function(obj, i) {
console.log(obj);
var repoFullName = obj[0].repository.full_name;
return <Repository repo={obj} repoName={repoFullName} key={repoFullName} />;
})
);
}

return (
Expand Down
14 changes: 5 additions & 9 deletions src/js/components/repository.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,21 +17,17 @@ var Repository = React.createClass({
},

render: function () {
var notifications = (
_.map(this.props.repo, function(notification, i) {
return (
<SingleNotification notification={notification} key={i} />
);
})
);

return (
<div>
<div className='row repository'>
<div className='col-xs-2'><img className='avatar' src={this.getAvatar()} /></div>
<div className='col-xs-10 name' onClick={this.openBrowser}>{this.props.repoName}</div>
</div>
{notifications}

{this.props.repo.map(function(obj, i) {
return <SingleNotification notification={obj} key={obj.id} />;
})}

</div>
);
}
Expand Down
13 changes: 9 additions & 4 deletions src/js/stores/notifications.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ var NotificationsStore = Reflux.createStore({
listenables: Actions,

init: function () {
this._notifications = undefined;
this._notifications = [];
},

updateTrayIcon: function (notifications) {
Expand Down Expand Up @@ -41,11 +41,16 @@ var NotificationsStore = Reflux.createStore({

onGetNotificationsCompleted: function (notifications) {
var groupedNotifications = _.groupBy(notifications, function(object){
return object.repository.name;
return object.repository.full_name;
});

this._notifications = groupedNotifications;
this.trigger(groupedNotifications);
var array= [];
_.map(groupedNotifications, function(obj, i) {
array.push(obj);
});

this._notifications = array;
this.trigger(this._notifications);
},

onGetNotificationsFailed: function (error) {
Expand Down