Use a static room summary provider to resolve room summaries through id and aliases (#3863)

* trying to debug why sometimes the value

is missing even if it appears in the room list

* static room provider implementation

* set the page size through the init

* removed reset filters on .cancel

since using the sop function is safer
This commit is contained in:
Mauro
2025-03-04 14:08:15 +01:00
committed by GitHub
parent 56d8af1d2e
commit 319441d527
16 changed files with 179 additions and 60 deletions
@@ -2268,12 +2268,13 @@ class ClientProxyMock: ClientProxyProtocol, @unchecked Sendable {
var underlyingIgnoredUsersPublisher: CurrentValuePublisher<[String]?, Never>!
var pusherNotificationClientIdentifier: String?
var roomSummaryProvider: RoomSummaryProviderProtocol?
var alternateRoomSummaryProvider: RoomSummaryProviderProtocol?
var staticRoomSummaryProvider: StaticRoomSummaryProviderProtocol?
var roomsToAwait: Set<String> {
get { return underlyingRoomsToAwait }
set(value) { underlyingRoomsToAwait = value }
}
var underlyingRoomsToAwait: Set<String>!
var alternateRoomSummaryProvider: RoomSummaryProviderProtocol?
var notificationSettings: NotificationSettingsProxyProtocol {
get { return underlyingNotificationSettings }
set(value) { underlyingNotificationSettings = value }
@@ -13589,58 +13590,17 @@ class RoomProxyMock: RoomProxyProtocol, @unchecked Sendable {
}
class RoomSummaryProviderMock: RoomSummaryProviderProtocol, @unchecked Sendable {
var roomListPublisher: CurrentValuePublisher<[RoomSummary], Never> {
get { return underlyingRoomListPublisher }
set(value) { underlyingRoomListPublisher = value }
}
var underlyingRoomListPublisher: CurrentValuePublisher<[RoomSummary], Never>!
var statePublisher: CurrentValuePublisher<RoomSummaryProviderState, Never> {
get { return underlyingStatePublisher }
set(value) { underlyingStatePublisher = value }
}
var underlyingStatePublisher: CurrentValuePublisher<RoomSummaryProviderState, Never>!
//MARK: - setRoomList
var setRoomListUnderlyingCallsCount = 0
var setRoomListCallsCount: Int {
get {
if Thread.isMainThread {
return setRoomListUnderlyingCallsCount
} else {
var returnValue: Int? = nil
DispatchQueue.main.sync {
returnValue = setRoomListUnderlyingCallsCount
}
return returnValue!
}
}
set {
if Thread.isMainThread {
setRoomListUnderlyingCallsCount = newValue
} else {
DispatchQueue.main.sync {
setRoomListUnderlyingCallsCount = newValue
}
}
}
var roomListPublisher: CurrentValuePublisher<[RoomSummary], Never> {
get { return underlyingRoomListPublisher }
set(value) { underlyingRoomListPublisher = value }
}
var setRoomListCalled: Bool {
return setRoomListCallsCount > 0
}
var setRoomListReceivedRoomList: RoomList?
var setRoomListReceivedInvocations: [RoomList] = []
var setRoomListClosure: ((RoomList) -> Void)?
var underlyingRoomListPublisher: CurrentValuePublisher<[RoomSummary], Never>!
func setRoomList(_ roomList: RoomList) {
setRoomListCallsCount += 1
setRoomListReceivedRoomList = roomList
DispatchQueue.main.async {
self.setRoomListReceivedInvocations.append(roomList)
}
setRoomListClosure?(roomList)
}
//MARK: - updateVisibleRange
var updateVisibleRangeUnderlyingCallsCount = 0
@@ -13723,6 +13683,47 @@ class RoomSummaryProviderMock: RoomSummaryProviderProtocol, @unchecked Sendable
}
setFilterClosure?(filter)
}
//MARK: - setRoomList
var setRoomListUnderlyingCallsCount = 0
var setRoomListCallsCount: Int {
get {
if Thread.isMainThread {
return setRoomListUnderlyingCallsCount
} else {
var returnValue: Int? = nil
DispatchQueue.main.sync {
returnValue = setRoomListUnderlyingCallsCount
}
return returnValue!
}
}
set {
if Thread.isMainThread {
setRoomListUnderlyingCallsCount = newValue
} else {
DispatchQueue.main.sync {
setRoomListUnderlyingCallsCount = newValue
}
}
}
}
var setRoomListCalled: Bool {
return setRoomListCallsCount > 0
}
var setRoomListReceivedRoomList: RoomList?
var setRoomListReceivedInvocations: [RoomList] = []
var setRoomListClosure: ((RoomList) -> Void)?
func setRoomList(_ roomList: RoomList) {
setRoomListCallsCount += 1
setRoomListReceivedRoomList = roomList
DispatchQueue.main.async {
self.setRoomListReceivedInvocations.append(roomList)
}
setRoomListClosure?(roomList)
}
}
class SecureBackupControllerMock: SecureBackupControllerProtocol, @unchecked Sendable {
var recoveryState: CurrentValuePublisher<SecureBackupRecoveryState, Never> {
@@ -14595,6 +14596,55 @@ class SessionVerificationControllerProxyMock: SessionVerificationControllerProxy
}
}
}
class StaticRoomSummaryProviderMock: StaticRoomSummaryProviderProtocol, @unchecked Sendable {
var roomListPublisher: CurrentValuePublisher<[RoomSummary], Never> {
get { return underlyingRoomListPublisher }
set(value) { underlyingRoomListPublisher = value }
}
var underlyingRoomListPublisher: CurrentValuePublisher<[RoomSummary], Never>!
//MARK: - setRoomList
var setRoomListUnderlyingCallsCount = 0
var setRoomListCallsCount: Int {
get {
if Thread.isMainThread {
return setRoomListUnderlyingCallsCount
} else {
var returnValue: Int? = nil
DispatchQueue.main.sync {
returnValue = setRoomListUnderlyingCallsCount
}
return returnValue!
}
}
set {
if Thread.isMainThread {
setRoomListUnderlyingCallsCount = newValue
} else {
DispatchQueue.main.sync {
setRoomListUnderlyingCallsCount = newValue
}
}
}
}
var setRoomListCalled: Bool {
return setRoomListCallsCount > 0
}
var setRoomListReceivedRoomList: RoomList?
var setRoomListReceivedInvocations: [RoomList] = []
var setRoomListClosure: ((RoomList) -> Void)?
func setRoomList(_ roomList: RoomList) {
setRoomListCallsCount += 1
setRoomListReceivedRoomList = roomList
DispatchQueue.main.async {
self.setRoomListReceivedInvocations.append(roomList)
}
setRoomListClosure?(roomList)
}
}
class TimelineControllerFactoryMock: TimelineControllerFactoryProtocol, @unchecked Sendable {
//MARK: - buildTimelineController