Skip to content
Snippets Groups Projects
Commit 1a8f94b6 authored by Taras's avatar Taras
Browse files

Remove ignored users section from people tab

parent c7635be2
No related branches found
No related tags found
No related merge requests found
...@@ -45,27 +45,21 @@ class PeopleDataSource @Inject constructor( ...@@ -45,27 +45,21 @@ class PeopleDataSource @Inject constructor(
suspend fun getPeopleList(query: String) = combine( suspend fun getPeopleList(query: String) = combine(
searchUserDataSource.searchKnownUsers(query), searchUserDataSource.searchKnownUsers(query),
searchUserDataSource.searchSuggestions(query), searchUserDataSource.searchSuggestions(query),
getIgnoredUserFlow(),
getProfileRoomMembersKnockFlow() getProfileRoomMembersKnockFlow()
) { knowUsers, suggestions, ignoredUsers, requests -> ) { knowUsers, suggestions, requests ->
withContext(Dispatchers.IO) { buildList(knowUsers, suggestions, ignoredUsers, requests) } withContext(Dispatchers.IO) { buildList(knowUsers, suggestions, requests) }
}.distinctUntilChanged() }.distinctUntilChanged()
suspend fun refreshRoomMembers() { suspend fun refreshRoomMembers() {
searchUserDataSource.loadAllRoomMembersIfNeeded() searchUserDataSource.loadAllRoomMembersIfNeeded()
} }
private fun getIgnoredUserFlow() =
session?.userService()?.getIgnoredUsersLive()?.asFlow() ?: flowOf()
private fun buildList( private fun buildList(
knowUsers: List<User>, knowUsers: List<User>,
suggestions: List<User>, suggestions: List<User>,
ignoredUsers: List<User>,
requests: List<KnockRequestListItem> requests: List<KnockRequestListItem>
): List<PeopleListItem> { ): List<PeopleListItem> {
val uniqueItemsList = mutableListOf<PeopleListItem>().apply { val uniqueItemsList = mutableListOf<PeopleListItem>().apply {
addAll(ignoredUsers.map { it.toPeopleUserListItem(PeopleItemType.Ignored) })
addAll(requests.map { it.toPeopleRequestListItem() }) addAll(requests.map { it.toPeopleRequestListItem() })
addAll(knowUsers.map { it.toPeopleUserListItem(getKnownUserItemType(it.userId)) }) addAll(knowUsers.map { it.toPeopleUserListItem(getKnownUserItemType(it.userId)) })
addAll(suggestions.map { it.toPeopleUserListItem(PeopleItemType.Suggestion) }) addAll(suggestions.map { it.toPeopleUserListItem(PeopleItemType.Suggestion) })
...@@ -96,10 +90,6 @@ class PeopleDataSource @Inject constructor( ...@@ -96,10 +90,6 @@ class PeopleDataSource @Inject constructor(
PeopleHeaderItem.suggestions, PeopleHeaderItem.suggestions,
uniqueItemsList.filter { it.type == PeopleItemType.Suggestion } uniqueItemsList.filter { it.type == PeopleItemType.Suggestion }
) )
addSection(
PeopleHeaderItem.ignoredUsers,
uniqueItemsList.filter { it.type == PeopleItemType.Ignored }
)
} }
} }
......
...@@ -38,8 +38,7 @@ class PeopleFragment : Fragment(R.layout.fragment_people), MenuProvider { ...@@ -38,8 +38,7 @@ class PeopleFragment : Fragment(R.layout.fragment_people), MenuProvider {
onRequestClicked = { userId, isAccepted -> onRequestClicked = { userId, isAccepted ->
if (showNoInternetConnection()) return@PeopleAdapter if (showNoInternetConnection()) return@PeopleAdapter
viewModel.onFollowRequestAnswered(userId, isAccepted) viewModel.onFollowRequestAnswered(userId, isAccepted)
}, }
onUnIgnore = { userId -> viewModel.unIgnoreUser(userId) }
) )
} }
...@@ -78,7 +77,6 @@ class PeopleFragment : Fragment(R.layout.fragment_people), MenuProvider { ...@@ -78,7 +77,6 @@ class PeopleFragment : Fragment(R.layout.fragment_people), MenuProvider {
} }
viewModel.followUserLiveData.observeResponse(this, viewModel.followUserLiveData.observeResponse(this,
success = { showSuccess(getString(R.string.request_sent)) }) success = { showSuccess(getString(R.string.request_sent)) })
viewModel.unIgnoreUserLiveData.observeResponse(this)
viewModel.followUserRequestLiveData.observeResponse(this) viewModel.followUserRequestLiveData.observeResponse(this)
} }
......
...@@ -15,13 +15,11 @@ import javax.inject.Inject ...@@ -15,13 +15,11 @@ import javax.inject.Inject
@HiltViewModel @HiltViewModel
class PeopleViewModel @Inject constructor( class PeopleViewModel @Inject constructor(
private val peopleDataSource: PeopleDataSource, private val peopleDataSource: PeopleDataSource
private val userOptionsDataSource: UserOptionsDataSource
) : ViewModel() { ) : ViewModel() {
val peopleLiveData = MutableLiveData<List<PeopleListItem>>() val peopleLiveData = MutableLiveData<List<PeopleListItem>>()
val followUserLiveData = SingleEventLiveData<Response<Unit?>>() val followUserLiveData = SingleEventLiveData<Response<Unit?>>()
val unIgnoreUserLiveData = SingleEventLiveData<Response<Unit?>>()
val followUserRequestLiveData = SingleEventLiveData<Response<Unit?>>() val followUserRequestLiveData = SingleEventLiveData<Response<Unit?>>()
init { init {
...@@ -36,18 +34,11 @@ class PeopleViewModel @Inject constructor( ...@@ -36,18 +34,11 @@ class PeopleViewModel @Inject constructor(
} }
} }
fun unIgnoreUser(userId: String) {
launchBg {
unIgnoreUserLiveData.postValue(userOptionsDataSource.unIgnoreSender(userId))
}
}
fun onFollowRequestAnswered(userId: String, accepted: Boolean) { fun onFollowRequestAnswered(userId: String, accepted: Boolean) {
launchBg { launchBg {
val result = if (accepted) peopleDataSource.acceptFollowRequest(userId) val result = if (accepted) peopleDataSource.acceptFollowRequest(userId)
else peopleDataSource.declineFollowRequest(userId) else peopleDataSource.declineFollowRequest(userId)
followUserRequestLiveData.postValue(result) followUserRequestLiveData.postValue(result)
} }
} }
} }
\ No newline at end of file
...@@ -9,7 +9,6 @@ import org.futo.circles.model.PeopleUserListItemPayload ...@@ -9,7 +9,6 @@ import org.futo.circles.model.PeopleUserListItemPayload
class PeopleAdapter( class PeopleAdapter(
private val onUserClicked: (String) -> Unit, private val onUserClicked: (String) -> Unit,
private val onUnIgnore: (String) -> Unit,
private val onRequestClicked: (String, Boolean) -> Unit private val onRequestClicked: (String, Boolean) -> Unit
) : BaseRvAdapter<PeopleListItem, PeopleViewHolder>(PayloadIdEntityCallback { old, new -> ) : BaseRvAdapter<PeopleListItem, PeopleViewHolder>(PayloadIdEntityCallback { old, new ->
if (new is PeopleUserListItem && old is PeopleUserListItem) { if (new is PeopleUserListItem && old is PeopleUserListItem) {
...@@ -28,10 +27,6 @@ class PeopleAdapter( ...@@ -28,10 +27,6 @@ class PeopleAdapter(
onRequestClicked(getItem(position).id, isAccepted) onRequestClicked(getItem(position).id, isAccepted)
} }
) )
PeopleItemType.Ignored -> PeopleIgnoredUserViewHolder(
parent,
onUnIgnore = { position -> onUnIgnore(getItem(position).id) }
)
else -> PeopleDefaultUserViewHolder( else -> PeopleDefaultUserViewHolder(
parent, parent,
onUserClicked = { position -> onUserClicked(getItem(position).id) } onUserClicked = { position -> onUserClicked(getItem(position).id) }
......
...@@ -24,28 +24,6 @@ abstract class PeopleViewHolder(view: View) : RecyclerView.ViewHolder(view) { ...@@ -24,28 +24,6 @@ abstract class PeopleViewHolder(view: View) : RecyclerView.ViewHolder(view) {
open fun bindPayload(data: PeopleUserListItemPayload) {} open fun bindPayload(data: PeopleUserListItemPayload) {}
} }
class PeopleIgnoredUserViewHolder(
parent: ViewGroup,
private val onUnIgnore: (Int) -> Unit
) : PeopleViewHolder(inflate(parent, ListItemPeopleIgnoredBinding::inflate)) {
private companion object : ViewBindingHolder
private val binding = baseBinding as ListItemPeopleIgnoredBinding
init {
onClick(binding.btnUnIgnore) { position -> onUnIgnore(position) }
}
override fun bind(data: PeopleListItem) {
(data as? PeopleUserListItem)?.let { binding.userItem.bind(it.user) }
}
override fun bindPayload(data: PeopleUserListItemPayload) {
data.user?.let { binding.userItem.bind(it) }
}
}
class PeopleDefaultUserViewHolder( class PeopleDefaultUserViewHolder(
parent: ViewGroup, parent: ViewGroup,
private val onUserClicked: (Int) -> Unit private val onUserClicked: (Int) -> Unit
......
...@@ -6,7 +6,7 @@ import org.futo.circles.core.model.CirclesUserSummary ...@@ -6,7 +6,7 @@ import org.futo.circles.core.model.CirclesUserSummary
import org.futo.circles.core.model.KnockRequestListItem import org.futo.circles.core.model.KnockRequestListItem
import org.futo.circles.core.model.toCircleUser import org.futo.circles.core.model.toCircleUser
enum class PeopleItemType { Header, Friend, Following, Follower, Request, Known, Suggestion, Ignored } enum class PeopleItemType { Header, Friend, Following, Follower, Request, Known, Suggestion }
sealed class PeopleListItem( sealed class PeopleListItem(
open val type: PeopleItemType open val type: PeopleItemType
) : IdEntity<String> ) : IdEntity<String>
...@@ -23,7 +23,6 @@ data class PeopleHeaderItem( ...@@ -23,7 +23,6 @@ data class PeopleHeaderItem(
val knownUsersHeader = PeopleHeaderItem(R.string.known_users) val knownUsersHeader = PeopleHeaderItem(R.string.known_users)
val suggestions = PeopleHeaderItem(R.string.suggestions) val suggestions = PeopleHeaderItem(R.string.suggestions)
val requests = PeopleHeaderItem(R.string.requests) val requests = PeopleHeaderItem(R.string.requests)
val ignoredUsers = PeopleHeaderItem(R.string.ignored_users)
} }
} }
......
...@@ -204,6 +204,7 @@ ...@@ -204,6 +204,7 @@
<string name="groups_empty_message">Create your first Group</string> <string name="groups_empty_message">Create your first Group</string>
<string name="circles_empty_message">Create your first Circle</string> <string name="circles_empty_message">Create your first Circle</string>
<string name="people_empty_message">Members of Circles and Groups you are joined will be shown here</string> <string name="people_empty_message">Members of Circles and Groups you are joined will be shown here</string>
<string name="ignored_users_empty_message">Ignored users will be shown here</string>
<string name="creating_timeline">Creating timeline</string> <string name="creating_timeline">Creating timeline</string>
<string name="group_topic_optional">Group topic (optional)</string> <string name="group_topic_optional">Group topic (optional)</string>
<string name="session">Session</string> <string name="session">Session</string>
......
package org.futo.circles.core.model package org.futo.circles.core.model
import org.futo.circles.core.base.list.IdEntity
data class CirclesUserSummary( data class CirclesUserSummary(
val id: String, override val id: String,
val name: String, val name: String,
val avatarUrl: String val avatarUrl: String
) ) : IdEntity<String>
\ No newline at end of file \ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment