@@ -37,9 +37,9 @@ import Toggle from 'components/Toggle/Toggle.react';
37
37
import Toolbar from 'components/Toolbar/Toolbar.react' ;
38
38
import { Directions } from 'lib/Constants' ;
39
39
import { Promise } from 'parse' ;
40
+ import { extractExpiration , extractPushTime } from 'lib/extractTime' ;
40
41
41
42
const PARSE_SERVER_SUPPORTS_AB_TESTING = false ;
42
- const PARSE_SERVER_SUPPORTS_SCHEDULE_PUSH = false ;
43
43
44
44
let formatErrorMessage = ( emptyInputMessages , key ) => {
45
45
let boldMessages = emptyInputMessages . map ( ( message ) => {
@@ -202,10 +202,14 @@ export default class PushNew extends DashboardView {
202
202
payload . badge = "Increment" ;
203
203
}
204
204
205
+ const push_time = extractPushTime ( changes ) ;
205
206
let body = {
207
+ data : payload ,
206
208
where : changes . target || new Parse . Query ( Parse . Installation ) ,
207
- data : payload
208
- }
209
+ push_time,
210
+ } ;
211
+ Object . assign ( body , extractExpiration ( changes ) ) ;
212
+
209
213
let audience_id = changes . audience_id ;
210
214
// Only set the audience ID if it is a saved audience.
211
215
if ( audience_id != PushConstants . NEW_SEGMENT_ID && audience_id != "everyone" ) {
@@ -631,7 +635,7 @@ export default class PushNew extends DashboardView {
631
635
legend = 'Choose your recipients.'
632
636
description = 'Send to everyone, or use an audience to target the right users.' >
633
637
< PushAudiencesData
634
- loaded = { true /* Parse Server doesn't support push audiences yet. once it does, pass: this.state.pushAudiencesFetched */ }
638
+ loaded = { this . state . pushAudiencesFetched }
635
639
schema = { schema }
636
640
pushAudiencesStore = { this . props . pushaudiences }
637
641
current = { fields . audience_id }
@@ -677,18 +681,21 @@ export default class PushNew extends DashboardView {
677
681
{ this . renderExperimentContent ( fields , setField ) }
678
682
</ Fieldset > : null ;
679
683
680
- const timeFieldsLegend = PARSE_SERVER_SUPPORTS_SCHEDULE_PUSH ?
684
+ const { push} = this . context . currentApp . serverInfo . features ;
685
+ const hasScheduledPushSupport = push && push . scheduledPush ;
686
+
687
+ const timeFieldsLegend = hasScheduledPushSupport ?
681
688
'Choose a delivery time' :
682
- 'Choose exiry ' ;
689
+ 'Choose expiry ' ;
683
690
684
- const timeFieldsDescription = PARSE_SERVER_SUPPORTS_SCHEDULE_PUSH ?
691
+ const timeFieldsDescription = hasScheduledPushSupport ?
685
692
'We can send the campaign immediately, or any time in the next 2 weeks.' :
686
693
"If your push hasn't been send by this time, it won't get sent." ;
687
694
688
- const deliveryTimeFields = PARSE_SERVER_SUPPORTS_SCHEDULE_PUSH ? < Fieldset
695
+ const deliveryTimeFields = hasScheduledPushSupport ? < Fieldset
689
696
legend = { timeFieldsLegend }
690
697
description = { timeFieldsDescription } >
691
- { PARSE_SERVER_SUPPORTS_SCHEDULE_PUSH ? this . renderDeliveryContent ( fields , setField ) : null }
698
+ { hasScheduledPushSupport ? this . renderDeliveryContent ( fields , setField ) : null }
692
699
< Field
693
700
label = { < Label text = 'Should this notification expire?' /> }
694
701
input = { < Toggle value = { fields . push_expires } onChange = { setField . bind ( null , 'push_expires' ) } /> } />
0 commit comments