@@ -8,33 +8,38 @@ function App() {
8
8
const [ APIData , setAPIData ] = useState ( false ) ;
9
9
useEffect ( ( ) => {
10
10
window . RequestNotifications = RequestNotifications ;
11
+ RequestNotifications ( ) ;
11
12
} , [ ] ) ;
12
13
13
14
const RequestNotifications = ( url ) => {
14
- axios . get ( url )
15
- . then ( ( response ) => {
16
- const notifications = response . data . notifications ;
17
- let notificationData = [ ] ;
18
- for ( let i = 0 ; i < notifications . length ; i ++ ) {
19
- var notificationItem = {
20
- id : notifications [ i ] . id ,
21
- featured : true ,
22
- unread : true ,
23
- image : < img width = { 40 } src = { notifications [ i ] . thumbnail } > </ img > ,
24
- message : notifications [ i ] . title ,
25
- href : notifications [ i ] . linkTitle ,
26
- timestamp : < Timestamp timestamp = { notifications [ i ] . created } /> ,
27
- content : < div >
28
- < b > { notifications [ i ] . title } </ b >
29
- < p > { notifications [ i ] . longDescription } </ p >
30
- < a href = { notifications [ i ] . link } > { notifications [ i ] . linkTitle } </ a >
31
- </ div >
32
- } ;
33
- notificationData . push ( notificationItem ) ;
34
- }
35
- setAPIData ( notificationData ) ;
36
- } ) ;
15
+ let getURL = url || process . env . NOTIFICATION_URL ;
16
+ if ( getURL ) {
17
+ axios . get ( getURL )
18
+ . then ( ( response ) => {
19
+ const notifications = response . data . notifications ;
20
+ let notificationData = [ ] ;
21
+ for ( let i = 0 ; i < notifications . length ; i ++ ) {
22
+ var notificationItem = {
23
+ id : notifications [ i ] . id ,
24
+ featured : true ,
25
+ unread : true ,
26
+ image : < img width = { 40 } src = { notifications [ i ] . thumbnail } > </ img > ,
27
+ message : notifications [ i ] . title ,
28
+ href : notifications [ i ] . linkTitle ,
29
+ timestamp : < Timestamp timestamp = { notifications [ i ] . created } /> ,
30
+ content : < div >
31
+ < b > { notifications [ i ] . title } </ b >
32
+ < p > { notifications [ i ] . longDescription } </ p >
33
+ < a href = { notifications [ i ] . link } > { notifications [ i ] . linkTitle } </ a >
34
+ </ div >
35
+ } ;
36
+ notificationData . push ( notificationItem ) ;
37
+ }
38
+ setAPIData ( notificationData ) ;
39
+ } ) ;
40
+ }
37
41
}
42
+
38
43
return APIData ?
39
44
< NotificationsPanel class = "NotificationsFlyout"
40
45
heading = "Notifications"
0 commit comments