Skip to content
Snippets Groups Projects
Commit 7ac27c7d authored by Taras's avatar Taras
Browse files

Fix system notices in known users

parent f7afd327
No related branches found
No related tags found
No related merge requests found
...@@ -40,6 +40,11 @@ fun Session.resolveUrl( ...@@ -40,6 +40,11 @@ fun Session.resolveUrl(
} }
} }
fun Session.getUserIdsToExclude() = mutableListOf(
myUserId,
"@notices:" + getServerDomain()
).toSet()
fun Session.getServerDomain() = myUserId.substringAfter(":") fun Session.getServerDomain() = myUserId.substringAfter(":")
fun Session.getKnownUsersFlow() = fun Session.getKnownUsersFlow() =
...@@ -49,7 +54,7 @@ fun Session.getKnownUsersFlow() = ...@@ -49,7 +54,7 @@ fun Session.getKnownUsersFlow() =
roomSummaries.forEach { summary -> roomSummaries.forEach { summary ->
summary.otherMemberIds.forEach { knowUsers.add(getOrFetchUser(it)) } summary.otherMemberIds.forEach { knowUsers.add(getOrFetchUser(it)) }
} }
knowUsers.toList().filterNot { it.userId == myUserId } knowUsers.toList().filterNot { getUserIdsToExclude().contains(it.userId) }
} }
suspend fun Session.getOrFetchUser(userId: String): User = suspend fun Session.getOrFetchUser(userId: String): User =
......
...@@ -7,6 +7,7 @@ import kotlinx.coroutines.flow.MutableStateFlow ...@@ -7,6 +7,7 @@ import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.flow.combine import kotlinx.coroutines.flow.combine
import kotlinx.coroutines.flow.distinctUntilChanged import kotlinx.coroutines.flow.distinctUntilChanged
import kotlinx.coroutines.flow.flowOn import kotlinx.coroutines.flow.flowOn
import org.futo.circles.core.extensions.getUserIdsToExclude
import org.futo.circles.core.mapping.toUserListItem import org.futo.circles.core.mapping.toUserListItem
import org.futo.circles.core.model.CirclesUserSummary import org.futo.circles.core.model.CirclesUserSummary
import org.futo.circles.core.model.HeaderItem import org.futo.circles.core.model.HeaderItem
...@@ -33,7 +34,7 @@ class SelectUsersDataSource @Inject constructor( ...@@ -33,7 +34,7 @@ class SelectUsersDataSource @Inject constructor(
private val room = session?.getRoom(roomId ?: "") private val room = session?.getRoom(roomId ?: "")
private val existingMembersIds = mutableListOf<String>().apply { private val existingMembersIds = mutableListOf<String>().apply {
session?.myUserId?.let { add(it)} addAll(session?.getUserIdsToExclude() ?: emptySet())
addAll(room?.membershipService()?.getRoomMembers( addAll(room?.membershipService()?.getRoomMembers(
roomMemberQueryParams { roomMemberQueryParams {
memberships = listOf(Membership.JOIN, Membership.INVITE, Membership.BAN) memberships = listOf(Membership.JOIN, Membership.INVITE, Membership.BAN)
......
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