Skip to content

Commit acdba5e

Browse files
Merge pull request #12 from ekonstantinidis/fix-results-json
Fix results json
2 parents 3d70f82 + cc58e04 commit acdba5e

File tree

3 files changed

+24
-22
lines changed

3 files changed

+24
-22
lines changed

src/js/components/notifications.js

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ var Notifications = React.createClass({
1818

1919
getInitialState: function() {
2020
return {
21-
notifications: {},
21+
notifications: [],
2222
loading: true
2323
};
2424
},
@@ -36,14 +36,7 @@ var Notifications = React.createClass({
3636
var wrapperClass = 'container-fluid main-container notifications';
3737
var self = this;
3838

39-
if (!_.isEmpty(this.state.notifications)) {
40-
notifications = (
41-
_.map(this.state.notifications, function(repo, i) {
42-
var repoFullName = repo[0].repository.full_name;
43-
return <Repository repo={repo} repoName={repoFullName} key={i} />;
44-
})
45-
);
46-
} else {
39+
if (_.isEmpty(this.state.notifications)) {
4740
wrapperClass += ' all-read';
4841
notifications = (
4942
<div>
@@ -52,6 +45,14 @@ var Notifications = React.createClass({
5245
<img className='img-responsive emoji' src='images/rocket.png' />
5346
</div>
5447
);
48+
} else {
49+
notifications = (
50+
this.state.notifications.map(function(obj, i) {
51+
console.log(obj);
52+
var repoFullName = obj[0].repository.full_name;
53+
return <Repository repo={obj} repoName={repoFullName} key={repoFullName} />;
54+
})
55+
);
5556
}
5657

5758
return (

src/js/components/repository.js

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,21 +17,17 @@ var Repository = React.createClass({
1717
},
1818

1919
render: function () {
20-
var notifications = (
21-
_.map(this.props.repo, function(notification, i) {
22-
return (
23-
<SingleNotification notification={notification} key={i} />
24-
);
25-
})
26-
);
27-
2820
return (
2921
<div>
3022
<div className='row repository'>
3123
<div className='col-xs-2'><img className='avatar' src={this.getAvatar()} /></div>
3224
<div className='col-xs-10 name' onClick={this.openBrowser}>{this.props.repoName}</div>
3325
</div>
34-
{notifications}
26+
27+
{this.props.repo.map(function(obj, i) {
28+
return <SingleNotification notification={obj} key={obj.id} />;
29+
})}
30+
3531
</div>
3632
);
3733
}

src/js/stores/notifications.js

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ var NotificationsStore = Reflux.createStore({
1010
listenables: Actions,
1111

1212
init: function () {
13-
this._notifications = undefined;
13+
this._notifications = [];
1414
},
1515

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

4242
onGetNotificationsCompleted: function (notifications) {
4343
var groupedNotifications = _.groupBy(notifications, function(object){
44-
return object.repository.name;
44+
return object.repository.full_name;
4545
});
4646

47-
this._notifications = groupedNotifications;
48-
this.trigger(groupedNotifications);
47+
var array= [];
48+
_.map(groupedNotifications, function(obj, i) {
49+
array.push(obj);
50+
});
51+
52+
this._notifications = array;
53+
this.trigger(this._notifications);
4954
},
5055

5156
onGetNotificationsFailed: function (error) {

0 commit comments

Comments
 (0)