Skip to content

Commit

Permalink
Fixed when receive string instead of an array
Browse files Browse the repository at this point in the history
My app was crashing when a user comes with a single group on IQ. This change solved the problem. (I am using prosody server)
  • Loading branch information
faogustavo authored Oct 30, 2017
1 parent 523da47 commit f988ba5
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions android/src/main/java/rnxmpp/utils/Parser.java
Original file line number Diff line number Diff line change
Expand Up @@ -65,12 +65,11 @@ static WritableMap parse(Node node) throws JSONException {
childArray.pushMap(Arguments.fromBundle(Arguments.toBundle(writableMap.getMap(childNode.getNodeName()))));
childArray.pushMap(parse(childNode));
writableMap.putArray(childNode.getNodeName(), childArray);
}
if (writableMap.hasKey(childNode.getNodeName())){
} else if (writableMap.hasKey(childNode.getNodeName()) && writableMap.getType(childNode.getNodeName()).equals(ReadableType.Array)){
WritableArray writableArray = fromArray(writableMap.getArray(childNode.getNodeName()));
writableArray.pushMap(parse(childNode));
writableMap.putArray(childNode.getNodeName(), writableArray);
}else{
} else {
NodeList checkTextChildNodes = childNode.getChildNodes();
if (checkTextChildNodes.getLength() == 1 && checkTextChildNodes.item(0).getNodeName().equals("#text")){
writableMap.putString(childNode.getNodeName(), checkTextChildNodes.item(0).getNodeValue());
Expand Down

0 comments on commit f988ba5

Please sign in to comment.