feat: sort comments in api
This commit is contained in:
parent
a0b22e8d56
commit
af1bc944d8
2 changed files with 23 additions and 7 deletions
|
@ -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) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue