Optimize leaving a room from home screen (#868)

* Use joinedMembersCount in HomeScreenViewModel

* Update matrix-rust-sdk to 1.0.62-alpha
This commit is contained in:
Alfonso Grillo
2023-05-09 17:06:19 +02:00
committed by GitHub
parent 1bd6e461ed
commit faefb00626
6 changed files with 39 additions and 15 deletions
@@ -111,8 +111,8 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/matrix-org/matrix-rust-components-swift",
"state" : {
"revision" : "1c1cd29d5720ecd0f6043b5d8f5a40d30dd5ec41",
"version" : "1.0.61-alpha"
"revision" : "3ea7abc7ceb51577724b499209f5b6b3fe2cfcde",
"version" : "1.0.62-alpha"
}
},
{
@@ -414,6 +414,21 @@ class RoomProxyMock: RoomProxyProtocol {
set(value) { underlyingMembersPublisher = value }
}
var underlyingMembersPublisher: AnyPublisher<[RoomMemberProxyProtocol], Never>!
var invitedMembersCount: UInt64 {
get { return underlyingInvitedMembersCount }
set(value) { underlyingInvitedMembersCount = value }
}
var underlyingInvitedMembersCount: UInt64!
var joinedMembersCount: UInt64 {
get { return underlyingJoinedMembersCount }
set(value) { underlyingJoinedMembersCount = value }
}
var underlyingJoinedMembersCount: UInt64!
var activeMembersCount: UInt64 {
get { return underlyingActiveMembersCount }
set(value) { underlyingActiveMembersCount = value }
}
var underlyingActiveMembersCount: UInt64!
//MARK: - loadAvatarURLForUserId
@@ -325,20 +325,11 @@ class HomeScreenViewModel: HomeScreenViewModelType, HomeScreenViewModelProtocol
return
}
guard !room.isPublic else {
if room.isPublic {
state.bindings.leaveRoomAlertItem = LeaveRoomAlertItem(roomId: roomId, state: .public)
return
} else {
state.bindings.leaveRoomAlertItem = room.joinedMembersCount > 1 ? LeaveRoomAlertItem(roomId: roomId, state: .private) : LeaveRoomAlertItem(roomId: roomId, state: .empty)
}
await room.updateMembers()
let joinedMembers = await room.membersPublisher.values.first()?.filter { $0.membership == .join }
guard let joinedMembers else {
state.bindings.alertInfo = AlertInfo(id: UUID(), title: L10n.errorUnknown)
return
}
state.bindings.leaveRoomAlertItem = joinedMembers.count > 1 ? LeaveRoomAlertItem(roomId: roomId, state: .private) : LeaveRoomAlertItem(roomId: roomId, state: .empty)
}
}
@@ -441,6 +441,18 @@ class RoomProxy: RoomProxyProtocol {
}
}
var invitedMembersCount: UInt64 {
room.invitedMembersCount()
}
var joinedMembersCount: UInt64 {
room.joinedMembersCount()
}
var activeMembersCount: UInt64 {
room.activeMembersCount()
}
// MARK: - Private
/// Force the timeline to load member details so it can populate sender profiles whenever we add a timeline listener
@@ -104,6 +104,12 @@ protocol RoomProxyProtocol {
func acceptInvitation() async -> Result<Void, RoomProxyError>
func fetchDetails(for eventID: String)
var invitedMembersCount: UInt64 { get }
var joinedMembersCount: UInt64 { get }
var activeMembersCount: UInt64 { get }
}
extension RoomProxyProtocol {
+1 -1
View File
@@ -42,7 +42,7 @@ include:
packages:
MatrixRustSDK:
url: https://github.com/matrix-org/matrix-rust-components-swift
exactVersion: 1.0.61-alpha
exactVersion: 1.0.62-alpha
# path: ../matrix-rust-sdk
DesignKit:
path: DesignKit