feat: Add ordering functionality for friends list

This commit is contained in:
2025-03-26 01:28:50 +03:00
parent 3dbf2bd8a4
commit 0ae05709db
9 changed files with 149 additions and 47 deletions
@@ -8,11 +8,13 @@ import com.slack.eithernet.ApiResult
interface FriendsRepository {
suspend fun getAllFriends(
order: String,
count: Int?,
offset: Int?
): ApiResult<FriendsInfo, RestApiErrorDomain>
suspend fun getFriends(
order: String,
count: Int?,
offset: Int?
): ApiResult<List<VkUser>, RestApiErrorDomain>
@@ -25,10 +25,11 @@ class FriendsRepositoryImpl(
) : FriendsRepository {
override suspend fun getAllFriends(
order: String,
count: Int?,
offset: Int?
): ApiResult<FriendsInfo, RestApiErrorDomain> = withContext(Dispatchers.IO) {
val friends = async { getFriends(count, offset) }.await()
val friends = async { getFriends(order, count, offset) }.await()
.successOrElse { failure ->
return@withContext failure
}
@@ -42,11 +43,12 @@ class FriendsRepositoryImpl(
}
override suspend fun getFriends(
order: String,
count: Int?,
offset: Int?
): ApiResult<List<VkUser>, RestApiErrorDomain> = withContext(Dispatchers.IO) {
val requestModel = GetFriendsRequest(
order = "hints",
order = order,
count = count,
offset = offset,
fields = VkConstants.USER_FIELDS