diff --git a/app/src/main/java/org/futo/circles/feature/circles/accept_invite/AcceptCircleInviteDialogFragment.kt b/app/src/main/java/org/futo/circles/feature/circles/accept_invite/AcceptCircleInviteDialogFragment.kt index cb4c0dfa666e11102df176d28437ae4e20d25ab7..b80a59facd90c79bab679963377991b4558f220a 100644 --- a/app/src/main/java/org/futo/circles/feature/circles/accept_invite/AcceptCircleInviteDialogFragment.kt +++ b/app/src/main/java/org/futo/circles/feature/circles/accept_invite/AcceptCircleInviteDialogFragment.kt @@ -74,6 +74,6 @@ class AcceptCircleInviteDialogFragment : override fun onRoomsListChanged(rooms: List<SelectableRoomListItem>) { binding.createCircleGroup.setIsVisible(rooms.isEmpty()) - binding.selectCircleGroup.setIsVisible(!rooms.isEmpty()) + binding.selectCircleGroup.setIsVisible(rooms.isNotEmpty()) } } \ No newline at end of file diff --git a/app/src/main/java/org/futo/circles/mapping/RoomSummaryMapping.kt b/app/src/main/java/org/futo/circles/mapping/RoomSummaryMapping.kt index 724e2c14ecf1e1d6119be795865df9ba4498619b..69f7820d733f82b0a2519595aabdfabcbe819f93 100644 --- a/app/src/main/java/org/futo/circles/mapping/RoomSummaryMapping.kt +++ b/app/src/main/java/org/futo/circles/mapping/RoomSummaryMapping.kt @@ -1,12 +1,9 @@ package org.futo.circles.mapping -import org.futo.circles.core.mapping.getInviterName import org.futo.circles.core.mapping.toRoomInfo import org.futo.circles.core.model.RoomInfo import org.futo.circles.core.provider.MatrixSessionProvider import org.futo.circles.core.utils.getTimelineRoomFor -import org.futo.circles.model.InvitedCircleListItem -import org.futo.circles.model.InvitedGroupListItem import org.futo.circles.model.JoinedCircleListItem import org.futo.circles.model.JoinedGroupListItem import org.futo.circles.model.TimelineRoomListItem @@ -29,14 +26,6 @@ fun RoomSummary.toJoinedGroupListItem() = JoinedGroupListItem( knockRequestsCount = getKnocksCount(roomId) ) -fun RoomSummary.toInviteGroupListItem(shouldBlurIcon: Boolean) = InvitedGroupListItem( - id = roomId, - info = toRoomInfo(), - isEncrypted = isEncrypted, - inviterName = getInviterName(), - shouldBlurIcon = shouldBlurIcon -) - fun RoomSummary.toJoinedCircleListItem(isShared: Boolean = false) = JoinedCircleListItem( id = roomId, info = toRoomInfo(), @@ -47,13 +36,6 @@ fun RoomSummary.toJoinedCircleListItem(isShared: Boolean = false) = JoinedCircle knockRequestsCount = getKnocksCount(getTimelineRoomFor(roomId)?.roomId ?: "") ) -fun RoomSummary.toInviteCircleListItem(shouldBlurIcon: Boolean) = InvitedCircleListItem( - id = roomId, - info = toRoomInfo(), - inviterName = getInviterName(), - shouldBlurIcon = shouldBlurIcon -) - private fun RoomSummary.getFollowersCount(): Int = getTimelineRoomFor(roomId)?.roomSummary()?.otherMemberIds?.size ?: 0 diff --git a/core/src/main/java/org/futo/circles/core/feature/room/RoomListHelper.kt b/core/src/main/java/org/futo/circles/core/feature/room/RoomListHelper.kt deleted file mode 100644 index eddf740b0b1585afb50906ffb1aae795bea13ea4..0000000000000000000000000000000000000000 --- a/core/src/main/java/org/futo/circles/core/feature/room/RoomListHelper.kt +++ /dev/null @@ -1,55 +0,0 @@ -package org.futo.circles.core.feature.room - -import androidx.lifecycle.asFlow -import kotlinx.coroutines.Dispatchers -import kotlinx.coroutines.flow.MutableStateFlow -import kotlinx.coroutines.flow.combine -import kotlinx.coroutines.flow.distinctUntilChanged -import kotlinx.coroutines.flow.update -import kotlinx.coroutines.withContext -import org.futo.circles.core.extensions.getKnownUsersFlow -import org.futo.circles.core.provider.MatrixSessionProvider -import org.matrix.android.sdk.api.session.room.model.RoomSummary -import org.matrix.android.sdk.api.session.room.model.RoomType -import org.matrix.android.sdk.api.session.room.roomSummaryQueryParams -import javax.inject.Inject - -class RoomListHelper @Inject constructor() { - - private val roomIdsToUnblurProfile = MutableStateFlow<Set<String>>(emptySet()) - - fun <T> getRoomsFlow( - buildList: (List<RoomSummary>, Set<String>, Set<String>) -> List<T>, - excludeRoomTypes: List<String>? = listOf(RoomType.SPACE) - ) = combine( - MatrixSessionProvider.getSessionOrThrow().roomService() - .getRoomSummariesLive(roomSummaryQueryParams { excludeType = excludeRoomTypes }) - .asFlow(), - MatrixSessionProvider.getSessionOrThrow().getKnownUsersFlow(), - roomIdsToUnblurProfile, - MatrixSessionProvider.getSessionOrThrow().roomService().getChangeMembershipsLive().asFlow() - ) { roomSummaries, knownUsers, roomIdsToUnblur, _ -> - withContext(Dispatchers.IO) { - buildList( - roomSummaries, - knownUsers.map { it.userId }.toSet(), - roomIdsToUnblur - ) - } - }.distinctUntilChanged() - - fun shouldBlurIconFor( - roomSummary: RoomSummary, - knownUserIds: Set<String>, - roomIdsToUnblur: Set<String> - ): Boolean { - val isKnownUser = knownUserIds.contains(roomSummary.inviterId) - val isRoomUnbluredByUser = roomIdsToUnblur.contains(roomSummary.roomId) - val hasIcon = roomSummary.avatarUrl.isNotEmpty() - return !isKnownUser && !isRoomUnbluredByUser && hasIcon - } - - fun unblurProfileImageFor(id: String) { - roomIdsToUnblurProfile.update { set -> set.toMutableSet().apply { add(id) } } - } -} \ No newline at end of file