@@ -13,13 +13,14 @@ var Notifications = React.createClass({
1313 mixins : [
1414 Reflux . connect ( NotificationsStore , 'notifications' ) ,
1515 Reflux . listenTo ( Actions . getNotifications . completed , 'completedNotifications' ) ,
16- Reflux . listenTo ( Actions . getNotifications . failed , 'completedNotifications ' )
16+ Reflux . listenTo ( Actions . getNotifications . failed , 'failedNotifications ' )
1717 ] ,
1818
1919 getInitialState : function ( ) {
2020 return {
2121 notifications : [ ] ,
22- loading : true
22+ loading : true ,
23+ errors : false
2324 } ;
2425 } ,
2526
@@ -28,36 +29,58 @@ var Notifications = React.createClass({
2829 } ,
2930
3031 completedNotifications : function ( ) {
31- this . setState ( { loading : false } ) ;
32+ this . setState ( {
33+ loading : false ,
34+ errors : false
35+ } ) ;
36+ } ,
37+
38+ failedNotifications : function ( ) {
39+ this . setState ( {
40+ loading : false ,
41+ errors : true
42+ } ) ;
3243 } ,
3344
3445 render : function ( ) {
35- var notifications ;
46+ var notifications , errors ;
3647 var wrapperClass = 'container-fluid main-container notifications' ;
3748
38- if ( _ . isEmpty ( this . state . notifications ) ) {
39- wrapperClass += ' all-read ' ;
40- notifications = (
49+ if ( this . state . errors ) {
50+ wrapperClass += ' errored ' ;
51+ errors = (
4152 < div >
42- < h2 > There are no notifications for you .</ h2 >
43- < h3 > All clean! </ h3 >
44- < img className = 'img-responsive emoji' src = 'images/rocket .png' />
53+ < h3 > Oops something went wrong .</ h3 >
54+ < h4 > Couldn't get your notifications. </ h4 >
55+ < img className = 'img-responsive emoji' src = 'images/error .png' />
4556 </ div >
4657 ) ;
4758 } else {
48- notifications = (
49- this . state . notifications . map ( function ( obj ) {
50- var repoFullName = obj [ 0 ] . repository . full_name ;
51- return < Repository repo = { obj } repoName = { repoFullName } key = { repoFullName } /> ;
52- } )
53- ) ;
59+ if ( _ . isEmpty ( this . state . notifications ) ) {
60+ wrapperClass += ' all-read' ;
61+ notifications = (
62+ < div >
63+ < h2 > There are no notifications for you.</ h2 >
64+ < h3 > All clean!</ h3 >
65+ < img className = 'img-responsive emoji' src = 'images/all-read.png' />
66+ </ div >
67+ ) ;
68+ } else {
69+ notifications = (
70+ this . state . notifications . map ( function ( obj ) {
71+ var repoFullName = obj [ 0 ] . repository . full_name ;
72+ return < Repository repo = { obj } repoName = { repoFullName } key = { repoFullName } /> ;
73+ } )
74+ ) ;
75+ }
5476 }
5577
5678 return (
5779 < div className = { wrapperClass } >
5880 < Loading className = 'loading-container' shouldShow = { this . state . loading } >
5981 < div className = 'loading-text' > working on it</ div >
6082 </ Loading >
83+ { errors }
6184 { notifications }
6285 </ div >
6386 ) ;
0 commit comments