Sort replies from oldest to newest #1057
2 changed files with 10 additions and 1 deletions
|
@ -11,7 +11,7 @@ import io.lbry.browser.utils.Helper;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
public class Comment {
|
public class Comment implements Comparable<Comment> {
|
||||||
public static final double LBC_COST = 1;
|
public static final double LBC_COST = 1;
|
||||||
public static final int MAX_LENGTH = 2000;
|
public static final int MAX_LENGTH = 2000;
|
||||||
|
|
||||||
|
@ -66,4 +66,9 @@ public class Comment {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int compareTo(Comment comment) {
|
||||||
|
return (int)(this.getTimestamp() - comment.getTimestamp());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,6 +8,7 @@ import org.json.JSONArray;
|
||||||
import org.json.JSONObject;
|
import org.json.JSONObject;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collections;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
@ -67,6 +68,9 @@ public class CommentListTask extends AsyncTask<Void, Void, List<Comment>> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Sort all replies from oldest to newest at once
|
||||||
|
Collections.sort(children);
|
||||||
|
|
||||||
for (Comment child : children) {
|
for (Comment child : children) {
|
||||||
for (Comment parent : comments) {
|
for (Comment parent : comments) {
|
||||||
if (parent.getId().equalsIgnoreCase(child.getParentId())) {
|
if (parent.getId().equalsIgnoreCase(child.getParentId())) {
|
||||||
|
|
Loading…
Reference in a new issue