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 kotlinx.coroutines.flow.Flow
interface FriendsUseCase {
fun getAllFriends(
order: String = "hints",
count: Int?,
offset: Int?
): Flow<State<FriendsInfo>>
fun getFriends(
order: String = "hints",
count: Int?,
offset: Int?
): Flow<State<List<VkUser>>>
@@ -11,19 +11,26 @@ import kotlinx.coroutines.flow.flow
class FriendsUseCaseImpl(private val repository: FriendsRepository) :
FriendsUseCase {
override fun getAllFriends(count: Int?, offset: Int?): Flow<State<FriendsInfo>> = flow {
override fun getAllFriends(order: String, count: Int?, offset: Int?): Flow<State<FriendsInfo>> = flow {
emit(State.Loading)
val newState = repository.getAllFriends(count, offset).mapToState()
val newState = repository.getAllFriends(order, count, offset).mapToState()
emit(newState)
}
override fun getFriends(
count: Int?, offset: Int?
order: String,
count: Int?,
offset: Int?
): Flow<State<List<VkUser>>> = flow {
emit(State.Loading)
val newState = repository.getFriends(count, offset).mapToState()
val newState = repository.getFriends(
order = order,
count = count,
offset = offset
).mapToState()
emit(newState)
}