Show OP badge on restored comment (#1016)

This commit is contained in:
Andrei Shpakovskiy 2022-09-21 07:53:19 +03:00 committed by GitHub
parent 9fad6fc961
commit 3c492d2626
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 17 additions and 2 deletions

View File

@ -987,8 +987,15 @@ public class CommentsRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerVi
}
public void editComment(String commentAuthor, String commentContentMarkdown, int position) {
if (commentAuthor != null)
editComment(commentAuthor, mVisibleComments.get(position).isSubmitter(), commentContentMarkdown, position);
}
public void editComment(String commentAuthor, boolean isSubmitter, String commentContentMarkdown, int position) {
if (commentAuthor != null) {
mVisibleComments.get(position).setAuthor(commentAuthor);
}
mVisibleComments.get(position).setSubmittedByAuthor(isSubmitter);
mVisibleComments.get(position).setCommentMarkdown(commentContentMarkdown);
if (mIsSingleCommentThreadMode) {

View File

@ -233,6 +233,10 @@ public class Comment implements Parcelable {
return isSubmitter;
}
public void setSubmittedByAuthor(boolean isSubmittedByAuthor) {
this.isSubmitter = isSubmittedByAuthor;
}
public boolean isModerator() {
return distinguished != null && distinguished.equals("moderator");
}

View File

@ -56,7 +56,7 @@ public class FetchRemovedComment {
comment.getLinkId(),
3000,
"asc",
"id,author,body",
"id,author,body,is_submitter",
after,
after + 43200, // 12 Hours later
"*").execute();
@ -107,6 +107,7 @@ public class FetchRemovedComment {
String id = result.getString(JSONUtils.ID_KEY);
String author = result.getString(JSONUtils.AUTHOR_KEY);
String body = Utils.modifyMarkdown(result.optString(JSONUtils.BODY_KEY).trim());
boolean isSubmitter = result.getBoolean(JSONUtils.IS_SUBMITTER_KEY);
if (id.equals(comment.getId()) &&
(!author.equals(comment.getAuthor()) ||
@ -115,6 +116,7 @@ public class FetchRemovedComment {
comment.setAuthor(author);
comment.setCommentMarkdown(body);
comment.setCommentRawText(body);
comment.setSubmittedByAuthor(isSubmitter);
return comment;
} else {
return null;

View File

@ -55,11 +55,13 @@ public class FetchRemovedCommentReveddit {
String id = result.getString(JSONUtils.ID_KEY);
String author = result.getString(JSONUtils.AUTHOR_KEY);
String body = Utils.modifyMarkdown(result.optString(JSONUtils.BODY_KEY).trim());
boolean isSubmitter = result.getBoolean(JSONUtils.IS_SUBMITTER_KEY);
if (id.equals(comment.getId()) && (!author.equals(comment.getAuthor()) || !body.equals(comment.getCommentRawText()))) {
comment.setAuthor(author);
comment.setCommentMarkdown(body);
comment.setCommentRawText(body);
comment.setSubmittedByAuthor(isSubmitter);
return comment;
} else {
return null;