@@ -48,16 +48,21 @@ export default class PushAudiencesIndex extends DashboardView {
48
48
}
49
49
}
50
50
51
- componentWillMount ( ) {
51
+ getAudienceData ( ) {
52
52
this . props . schema . dispatch ( SchemaStore . ActionTypes . FETCH ) ;
53
- this . props . pushaudiences . dispatch ( PushAudiencesStore . ActionTypes . FETCH ,
53
+ return this . props . pushaudiences . dispatch ( PushAudiencesStore . ActionTypes . FETCH ,
54
54
{
55
55
limit : PushConstants . SHOW_MORE_LIMIT ,
56
56
min : PushConstants . INITIAL_PAGE_SIZE ,
57
57
xhrKey : XHR_KEY ,
58
- } ) . then ( ( ) => {
58
+ } )
59
+ }
59
60
60
- } ) . always ( ( ) => {
61
+ componentWillMount ( ) {
62
+ this . getAudienceData ( ) . then ( ( ) => {
63
+ this . setState ( { loading : false } ) ;
64
+ } ) . catch ( ( err ) => {
65
+ console . error ( err )
61
66
this . setState ( { loading : false } ) ;
62
67
} ) ;
63
68
this . context . currentApp . fetchAvailableDevices ( ) . then ( ( { available_devices } ) => {
@@ -109,6 +114,7 @@ export default class PushAudiencesIndex extends DashboardView {
109
114
}
110
115
111
116
handleSendPush ( objectId ) {
117
+
112
118
history . push ( this . context . generatePath ( `push/new?audienceId=${ objectId } ` ) ) ;
113
119
}
114
120
@@ -192,6 +198,14 @@ export default class PushAudiencesIndex extends DashboardView {
192
198
this . setState ( {
193
199
showCreateAudienceModal : false ,
194
200
} ) ;
201
+ // After create the new audience update audience's list to get the new objectId
202
+ this . setState ( { loading : true } ) ;
203
+ this . getAudienceData ( ) . then ( ( ) => {
204
+ this . setState ( { loading : false } ) ;
205
+ } ) . catch ( err => {
206
+ console . error ( err )
207
+ this . setState ( { loading : false } ) ;
208
+ } )
195
209
} ) ;
196
210
}
197
211
0 commit comments