Skip to content

Commit 432a2ea

Browse files
committed
Fix audiences
1 parent 22e7431 commit 432a2ea

File tree

2 files changed

+21
-5
lines changed

2 files changed

+21
-5
lines changed

src/dashboard/Push/PushAudiencesIndex.react.js

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,16 +48,21 @@ export default class PushAudiencesIndex extends DashboardView {
4848
}
4949
}
5050

51-
componentWillMount() {
51+
getAudienceData() {
5252
this.props.schema.dispatch(SchemaStore.ActionTypes.FETCH);
53-
this.props.pushaudiences.dispatch(PushAudiencesStore.ActionTypes.FETCH,
53+
return this.props.pushaudiences.dispatch(PushAudiencesStore.ActionTypes.FETCH,
5454
{
5555
limit: PushConstants.SHOW_MORE_LIMIT,
5656
min: PushConstants.INITIAL_PAGE_SIZE,
5757
xhrKey: XHR_KEY,
58-
}).then(() => {
58+
})
59+
}
5960

60-
}).always(() => {
61+
componentWillMount() {
62+
this.getAudienceData().then(() => {
63+
this.setState({ loading: false });
64+
}).catch((err) => {
65+
console.error(err)
6166
this.setState({ loading: false });
6267
});
6368
this.context.currentApp.fetchAvailableDevices().then(({ available_devices }) => {
@@ -109,6 +114,7 @@ export default class PushAudiencesIndex extends DashboardView {
109114
}
110115

111116
handleSendPush(objectId) {
117+
112118
history.push(this.context.generatePath(`push/new?audienceId=${objectId}`));
113119
}
114120

@@ -192,6 +198,14 @@ export default class PushAudiencesIndex extends DashboardView {
192198
this.setState({
193199
showCreateAudienceModal: false,
194200
});
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+
})
195209
});
196210
}
197211

src/lib/stores/PushAudiencesStore.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ function PushAudiencesStore(state, action) {
3434
if (action.app.serverInfo.features.push.pushAudiences) {
3535
let promise = action.app.apiRequest(
3636
'GET',
37-
action.limit ? `push_audiences?audience_limit=${action.limit}` : 'push_audiences',
37+
action.limit ? `push_audiences?limit=${action.limit}` : 'push_audiences',
3838
{},
3939
{ useMasterKey: true }
4040
);
@@ -43,6 +43,8 @@ function PushAudiencesStore(state, action) {
4343
//
4444
return promise.then(({ results, showMore }) => {
4545
return Map({ lastFetch: new Date(), audiences: List(results), showMore: showMore});
46+
}).catch(err => {
47+
console.error(err);
4648
});
4749
} else {
4850
return Parse.Promise.as(state);

0 commit comments

Comments
 (0)