Skip to content

Commit

Permalink
add query for followers
Browse files Browse the repository at this point in the history
  • Loading branch information
stslex committed Feb 23, 2024
1 parent 00665d6 commit 828d2aa
Show file tree
Hide file tree
Showing 8 changed files with 24 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ class MockProfileClientImpl : ProfileClient {

override suspend fun getFollowers(
uuid: String,
query: String,
page: Int,
pageSize: Int
): UserFollowerResponse {
Expand All @@ -92,6 +93,7 @@ class MockProfileClientImpl : ProfileClient {

override suspend fun getFollowing(
uuid: String,
query: String,
page: Int,
pageSize: Int
): UserFollowerResponse {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,14 @@ interface ProfileClient {

suspend fun getFollowers(
uuid: String,
query: String,
page: Int,
pageSize: Int
): UserFollowerResponse

suspend fun getFollowing(
uuid: String,
query: String,
page: Int,
pageSize: Int
): UserFollowerResponse
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,23 +58,27 @@ class ProfileClientImpl(

override suspend fun getFollowers(
uuid: String,
query: String,
page: Int,
pageSize: Int
): UserFollowerResponse = client.request {
get("$HOST/followers") {
parameter("uuid", uuid)
parameter("query", query)
parameter("page", page)
parameter("page_size", pageSize)
}.body()
}

override suspend fun getFollowing(
uuid: String,
query: String,
page: Int,
pageSize: Int
): UserFollowerResponse = client.request {
get("$HOST/following") {
parameter("uuid", uuid)
parameter("query", query)
parameter("page", page)
parameter("page_size", pageSize)
}.body()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,14 @@ interface FollowerRepository {

fun getFollowers(
uuid: String,
query: String,
page: Int,
pageSize: Int
): Flow<List<FollowerDataModel>>

fun getFollowing(
uuid: String,
query: String,
page: Int,
pageSize: Int
): Flow<List<FollowerDataModel>>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,13 @@ class FollowerRepositoryImpl(

override fun getFollowers(
uuid: String,
query: String,
page: Int,
pageSize: Int
): Flow<List<FollowerDataModel>> = flow {
val result = client.getFollowers(
uuid = uuid,
query = query,
page = page,
pageSize = pageSize
).toData()
Expand All @@ -25,11 +27,13 @@ class FollowerRepositoryImpl(

override fun getFollowing(
uuid: String,
query: String,
page: Int,
pageSize: Int
): Flow<List<FollowerDataModel>> = flow {
val result = client.getFollowing(
uuid = uuid,
query = query,
page = page,
pageSize = pageSize
).toData()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,14 @@ interface FollowerInteractor {

fun getFollowers(
uuid: String,
query: String,
page: Int,
pageSize: Int
): Flow<List<FollowerModel>>

fun getFollowing(
uuid: String,
query: String,
page: Int,
pageSize: Int
): Flow<List<FollowerModel>>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,22 +12,27 @@ class FollowerInteractorImpl(

override fun getFollowers(
uuid: String,
page: Int, pageSize: Int
query: String,
page: Int,
pageSize: Int
): Flow<List<FollowerModel>> = repository
.getFollowers(
uuid = uuid,
query = query,
page = page,
pageSize = pageSize
)
.map { it.toUI() }

override fun getFollowing(
uuid: String,
query: String,
page: Int,
pageSize: Int
): Flow<List<FollowerModel>> = repository
.getFollowing(
uuid = uuid,
query = query,
page = page,
pageSize = pageSize
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,12 +72,14 @@ class FollowerStore(
loadingJob = when (val type = currentState.type) {
is FollowerScreenArgs.Follower -> interactor.getFollowers(
uuid = type.uuid,
query = "", // todo add query
page = page,
pageSize = PAGE_SIZE
)

is FollowerScreenArgs.Following -> interactor.getFollowing(
uuid = type.uuid,
query = "", // todo add query
page = page,
pageSize = PAGE_SIZE
)
Expand Down

0 comments on commit 828d2aa

Please sign in to comment.