feat: sort comments in api

This commit is contained in:
rebelonion 2024-03-17 20:52:39 -05:00
parent a0b22e8d56
commit af1bc944d8
2 changed files with 23 additions and 7 deletions

View file

@ -31,12 +31,15 @@ object CommentsAPI {
var isMod: Boolean = false
var totalVotes: Int = 0
suspend fun getCommentsForId(id: Int, page: Int = 1, tag: Int?): CommentResponse? {
suspend fun getCommentsForId(id: Int, page: Int = 1, tag: Int?, sort: String?): CommentResponse? {
var url = "$address/comments/$id/$page"
val request = requestBuilder()
tag?.let {
url += "?tag=$it"
}
sort?.let {
url += if (tag != null) "&sort=$it" else "?sort=$it"
}
val json = try {
request.get(url)
} catch (e: IOException) {