Skip to content

Commit

Permalink
Refactored code
Browse files Browse the repository at this point in the history
according to review
  • Loading branch information
litetex committed Feb 21, 2022
1 parent 520838b commit ce65dc0
Showing 1 changed file with 4 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,8 @@ public InfoItemsPage<CommentsInfoItem> getInitialPage()

/**
* Finds the initial comments token and initializes commentsDisabled.
* Also set
* <br/>
* Also sets {@link #optCommentsDisabled}.
*
* @return the continuation token or null if none was found
*/
Expand All @@ -85,14 +86,12 @@ private String findInitialCommentsToken() throws ExtractionException {
// Only use JsonObjects
.filter(JsonObject.class::isInstance)
.map(JsonObject.class::cast)
// Only process JsonObjects that have a itemSectionRenderer
.filter(jObj -> jObj.has("itemSectionRenderer"))
// Check if the comment-section is present
.filter(jObj -> {
try {
return "comments-section".equals(
JsonUtils.getString(jObj, "itemSectionRenderer.targetId"));
} catch (final ParsingException ex) {
} catch (final ParsingException ignored) {
return false;
}
})
Expand All @@ -105,7 +104,7 @@ private String findInitialCommentsToken() throws ExtractionException {
.getObject("itemSectionRenderer")
.getArray("contents").getObject(0),
"continuationItemRenderer.continuationEndpoint.continuationCommand.token");
} catch (final ParsingException ex) {
} catch (final ParsingException ignored) {
return null;
}
})
Expand Down

0 comments on commit ce65dc0

Please sign in to comment.