Past Pushes: fix error if alert field is not exist in payload#433
Past Pushes: fix error if alert field is not exist in payload#433peterdotjs merged 3 commits intoparse-community:masterfrom
Conversation
|
By analyzing the blame information on this pull request, we identified @drew-gross, @JeremyPlease and @durunvo to be potential reviewers. |
| @@ -141,15 +141,11 @@ let getPushName = (pushData) => { | |||
| ); | |||
| } else { | |||
| let payload = pushData[PushConstants.PAYLOAD_FIELD]; | |||
There was a problem hiding this comment.
You could just change this line to: let payload = pushData[PushConstants.PAYLOAD_FIELD] || '';
This should achieve what you are looking for. While keeping the existing alert type checks in place.
|
@hermanliang updated the pull request. |
|
@hermanliang updated the pull request. |
| return payload.alert; | ||
| } | ||
| return payload.alert ? JSON.stringify(payload.alert) : payload; | ||
| return payload.alert ? JSON.stringify(payload.alert) : JSON.stringify(payload); |
There was a problem hiding this comment.
Cool! One nit is that when the payload is empty string JSON.stringify('') results in a double string outputted. We'll only need stringify if payload is an object. Once you've added that check its go to merge. Thanks!
|
@hermanliang updated the pull request. |
1 similar comment
|
@hermanliang updated the pull request. |
| return payload.alert ? JSON.stringify(payload.alert) : payload; | ||
| return payload.alert ? JSON.stringify(payload.alert) : JSON.stringify(payload); | ||
| } else { | ||
| return ''; |
There was a problem hiding this comment.
If payload is not an object
return ''
No description provided.