Fix NPE and add comments disabled field.

This commit is contained in:
FireMasterK 2021-07-31 16:09:06 +05:30
parent 3bc9d05fc4
commit 9d09232319
No known key found for this signature in database
GPG key ID: 49451E4482CC5BCD
2 changed files with 7 additions and 5 deletions

View file

@ -477,8 +477,8 @@ public class ResponseHelper {
info.getRelatedItems().forEach(comment -> {
comments.add(new Comment(comment.getUploaderName(), rewriteURL(comment.getUploaderAvatarUrl()),
comment.getCommentId(), comment.getCommentText(), comment.getTextualUploadDate(),
comment.getUploaderUrl().substring(19), comment.getLikeCount(), comment.isHeartedByUploader(),
comment.isPinned(), comment.isUploaderVerified()));
optionalSubstring(comment.getUploaderUrl(), 19), comment.getLikeCount(),
comment.isHeartedByUploader(), comment.isPinned(), comment.isUploaderVerified()));
});
String nextpage = null;
@ -487,7 +487,7 @@ public class ResponseHelper {
nextpage = Constants.mapper.writeValueAsString(page);
}
CommentsPage commentsItem = new CommentsPage(comments, nextpage);
CommentsPage commentsItem = new CommentsPage(comments, nextpage, info.isCommentsDisabled());
return Constants.mapper.writeValueAsBytes(commentsItem);
@ -516,7 +516,7 @@ public class ResponseHelper {
nextpage = Constants.mapper.writeValueAsString(page);
}
CommentsPage commentsItem = new CommentsPage(comments, nextpage);
CommentsPage commentsItem = new CommentsPage(comments, nextpage, init.isCommentsDisabled());
return Constants.mapper.writeValueAsBytes(commentsItem);

View file

@ -6,9 +6,11 @@ public class CommentsPage {
public List<Comment> comments;
public String nextpage;
public boolean disabled;
public CommentsPage(List<Comment> comments, String nextpage) {
public CommentsPage(List<Comment> comments, String nextpage, boolean disabled) {
this.comments = comments;
this.nextpage = nextpage;
this.disabled = disabled;
}
}