Register for room info updates

This commit is contained in:
Stefan Ceriu
2023-08-25 12:28:37 +03:00
committed by Stefan Ceriu
parent 78d1fd631b
commit 734d8bba04
7 changed files with 142 additions and 117 deletions
@@ -813,11 +813,11 @@ class RoomProxyMock: RoomProxyProtocol {
set(value) { underlyingActiveMembersCount = value } set(value) { underlyingActiveMembersCount = value }
} }
var underlyingActiveMembersCount: Int! var underlyingActiveMembersCount: Int!
var updatesPublisher: AnyPublisher<[TimelineDiff], Never> { var stateUpdatesPublisher: AnyPublisher<Void, Never> {
get { return underlyingUpdatesPublisher } get { return underlyingStateUpdatesPublisher }
set(value) { underlyingUpdatesPublisher = value } set(value) { underlyingStateUpdatesPublisher = value }
} }
var underlyingUpdatesPublisher: AnyPublisher<[TimelineDiff], Never>! var underlyingStateUpdatesPublisher: AnyPublisher<Void, Never>!
var timelineProvider: RoomTimelineProviderProtocol { var timelineProvider: RoomTimelineProviderProtocol {
get { return underlyingTimelineProvider } get { return underlyingTimelineProvider }
set(value) { underlyingTimelineProvider = value } set(value) { underlyingTimelineProvider = value }
@@ -6,7 +6,7 @@ import Foundation
import MatrixRustSDK import MatrixRustSDK
class SDKClientMock: SDKClientProtocol { class SDKClientMock: SDKClientProtocol {
//MARK: - `accountData` //MARK: - accountData
public var accountDataEventTypeThrowableError: Error? public var accountDataEventTypeThrowableError: Error?
public var accountDataEventTypeCallsCount = 0 public var accountDataEventTypeCallsCount = 0
@@ -18,20 +18,20 @@ class SDKClientMock: SDKClientProtocol {
public var accountDataEventTypeReturnValue: String? public var accountDataEventTypeReturnValue: String?
public var accountDataEventTypeClosure: ((String) throws -> String?)? public var accountDataEventTypeClosure: ((String) throws -> String?)?
public func `accountData`(`eventType`: String) throws -> String? { public func accountData(eventType: String) throws -> String? {
if let error = accountDataEventTypeThrowableError { if let error = accountDataEventTypeThrowableError {
throw error throw error
} }
accountDataEventTypeCallsCount += 1 accountDataEventTypeCallsCount += 1
accountDataEventTypeReceivedEventType = eventType accountDataEventTypeReceivedEventType = eventType
accountDataEventTypeReceivedInvocations.append(`eventType`) accountDataEventTypeReceivedInvocations.append(eventType)
if let accountDataEventTypeClosure = accountDataEventTypeClosure { if let accountDataEventTypeClosure = accountDataEventTypeClosure {
return try accountDataEventTypeClosure(`eventType`) return try accountDataEventTypeClosure(eventType)
} else { } else {
return accountDataEventTypeReturnValue return accountDataEventTypeReturnValue
} }
} }
//MARK: - `accountUrl` //MARK: - accountUrl
public var accountUrlCallsCount = 0 public var accountUrlCallsCount = 0
public var accountUrlCalled: Bool { public var accountUrlCalled: Bool {
@@ -40,7 +40,7 @@ class SDKClientMock: SDKClientProtocol {
public var accountUrlReturnValue: String? public var accountUrlReturnValue: String?
public var accountUrlClosure: (() -> String?)? public var accountUrlClosure: (() -> String?)?
public func `accountUrl`() -> String? { public func accountUrl() -> String? {
accountUrlCallsCount += 1 accountUrlCallsCount += 1
if let accountUrlClosure = accountUrlClosure { if let accountUrlClosure = accountUrlClosure {
return accountUrlClosure() return accountUrlClosure()
@@ -48,7 +48,7 @@ class SDKClientMock: SDKClientProtocol {
return accountUrlReturnValue return accountUrlReturnValue
} }
} }
//MARK: - `avatarUrl` //MARK: - avatarUrl
public var avatarUrlThrowableError: Error? public var avatarUrlThrowableError: Error?
public var avatarUrlCallsCount = 0 public var avatarUrlCallsCount = 0
@@ -58,7 +58,7 @@ class SDKClientMock: SDKClientProtocol {
public var avatarUrlReturnValue: String? public var avatarUrlReturnValue: String?
public var avatarUrlClosure: (() throws -> String?)? public var avatarUrlClosure: (() throws -> String?)?
public func `avatarUrl`() throws -> String? { public func avatarUrl() throws -> String? {
if let error = avatarUrlThrowableError { if let error = avatarUrlThrowableError {
throw error throw error
} }
@@ -69,7 +69,7 @@ class SDKClientMock: SDKClientProtocol {
return avatarUrlReturnValue return avatarUrlReturnValue
} }
} }
//MARK: - `cachedAvatarUrl` //MARK: - cachedAvatarUrl
public var cachedAvatarUrlThrowableError: Error? public var cachedAvatarUrlThrowableError: Error?
public var cachedAvatarUrlCallsCount = 0 public var cachedAvatarUrlCallsCount = 0
@@ -79,7 +79,7 @@ class SDKClientMock: SDKClientProtocol {
public var cachedAvatarUrlReturnValue: String? public var cachedAvatarUrlReturnValue: String?
public var cachedAvatarUrlClosure: (() throws -> String?)? public var cachedAvatarUrlClosure: (() throws -> String?)?
public func `cachedAvatarUrl`() throws -> String? { public func cachedAvatarUrl() throws -> String? {
if let error = cachedAvatarUrlThrowableError { if let error = cachedAvatarUrlThrowableError {
throw error throw error
} }
@@ -90,7 +90,7 @@ class SDKClientMock: SDKClientProtocol {
return cachedAvatarUrlReturnValue return cachedAvatarUrlReturnValue
} }
} }
//MARK: - `createRoom` //MARK: - createRoom
public var createRoomRequestThrowableError: Error? public var createRoomRequestThrowableError: Error?
public var createRoomRequestCallsCount = 0 public var createRoomRequestCallsCount = 0
@@ -102,20 +102,20 @@ class SDKClientMock: SDKClientProtocol {
public var createRoomRequestReturnValue: String! public var createRoomRequestReturnValue: String!
public var createRoomRequestClosure: ((CreateRoomParameters) throws -> String)? public var createRoomRequestClosure: ((CreateRoomParameters) throws -> String)?
public func `createRoom`(`request`: CreateRoomParameters) throws -> String { public func createRoom(request: CreateRoomParameters) throws -> String {
if let error = createRoomRequestThrowableError { if let error = createRoomRequestThrowableError {
throw error throw error
} }
createRoomRequestCallsCount += 1 createRoomRequestCallsCount += 1
createRoomRequestReceivedRequest = request createRoomRequestReceivedRequest = request
createRoomRequestReceivedInvocations.append(`request`) createRoomRequestReceivedInvocations.append(request)
if let createRoomRequestClosure = createRoomRequestClosure { if let createRoomRequestClosure = createRoomRequestClosure {
return try createRoomRequestClosure(`request`) return try createRoomRequestClosure(request)
} else { } else {
return createRoomRequestReturnValue return createRoomRequestReturnValue
} }
} }
//MARK: - `deviceId` //MARK: - deviceId
public var deviceIdThrowableError: Error? public var deviceIdThrowableError: Error?
public var deviceIdCallsCount = 0 public var deviceIdCallsCount = 0
@@ -125,7 +125,7 @@ class SDKClientMock: SDKClientProtocol {
public var deviceIdReturnValue: String! public var deviceIdReturnValue: String!
public var deviceIdClosure: (() throws -> String)? public var deviceIdClosure: (() throws -> String)?
public func `deviceId`() throws -> String { public func deviceId() throws -> String {
if let error = deviceIdThrowableError { if let error = deviceIdThrowableError {
throw error throw error
} }
@@ -136,7 +136,7 @@ class SDKClientMock: SDKClientProtocol {
return deviceIdReturnValue return deviceIdReturnValue
} }
} }
//MARK: - `displayName` //MARK: - displayName
public var displayNameThrowableError: Error? public var displayNameThrowableError: Error?
public var displayNameCallsCount = 0 public var displayNameCallsCount = 0
@@ -146,7 +146,7 @@ class SDKClientMock: SDKClientProtocol {
public var displayNameReturnValue: String! public var displayNameReturnValue: String!
public var displayNameClosure: (() throws -> String)? public var displayNameClosure: (() throws -> String)?
public func `displayName`() throws -> String { public func displayName() throws -> String {
if let error = displayNameThrowableError { if let error = displayNameThrowableError {
throw error throw error
} }
@@ -157,7 +157,7 @@ class SDKClientMock: SDKClientProtocol {
return displayNameReturnValue return displayNameReturnValue
} }
} }
//MARK: - `getDmRoom` //MARK: - getDmRoom
public var getDmRoomUserIdThrowableError: Error? public var getDmRoomUserIdThrowableError: Error?
public var getDmRoomUserIdCallsCount = 0 public var getDmRoomUserIdCallsCount = 0
@@ -169,20 +169,20 @@ class SDKClientMock: SDKClientProtocol {
public var getDmRoomUserIdReturnValue: Room? public var getDmRoomUserIdReturnValue: Room?
public var getDmRoomUserIdClosure: ((String) throws -> Room?)? public var getDmRoomUserIdClosure: ((String) throws -> Room?)?
public func `getDmRoom`(`userId`: String) throws -> Room? { public func getDmRoom(userId: String) throws -> Room? {
if let error = getDmRoomUserIdThrowableError { if let error = getDmRoomUserIdThrowableError {
throw error throw error
} }
getDmRoomUserIdCallsCount += 1 getDmRoomUserIdCallsCount += 1
getDmRoomUserIdReceivedUserId = userId getDmRoomUserIdReceivedUserId = userId
getDmRoomUserIdReceivedInvocations.append(`userId`) getDmRoomUserIdReceivedInvocations.append(userId)
if let getDmRoomUserIdClosure = getDmRoomUserIdClosure { if let getDmRoomUserIdClosure = getDmRoomUserIdClosure {
return try getDmRoomUserIdClosure(`userId`) return try getDmRoomUserIdClosure(userId)
} else { } else {
return getDmRoomUserIdReturnValue return getDmRoomUserIdReturnValue
} }
} }
//MARK: - `getMediaContent` //MARK: - getMediaContent
public var getMediaContentMediaSourceThrowableError: Error? public var getMediaContentMediaSourceThrowableError: Error?
public var getMediaContentMediaSourceCallsCount = 0 public var getMediaContentMediaSourceCallsCount = 0
@@ -194,32 +194,32 @@ class SDKClientMock: SDKClientProtocol {
public var getMediaContentMediaSourceReturnValue: [UInt8]! public var getMediaContentMediaSourceReturnValue: [UInt8]!
public var getMediaContentMediaSourceClosure: ((MediaSource) throws -> [UInt8])? public var getMediaContentMediaSourceClosure: ((MediaSource) throws -> [UInt8])?
public func `getMediaContent`(`mediaSource`: MediaSource) throws -> [UInt8] { public func getMediaContent(mediaSource: MediaSource) throws -> [UInt8] {
if let error = getMediaContentMediaSourceThrowableError { if let error = getMediaContentMediaSourceThrowableError {
throw error throw error
} }
getMediaContentMediaSourceCallsCount += 1 getMediaContentMediaSourceCallsCount += 1
getMediaContentMediaSourceReceivedMediaSource = mediaSource getMediaContentMediaSourceReceivedMediaSource = mediaSource
getMediaContentMediaSourceReceivedInvocations.append(`mediaSource`) getMediaContentMediaSourceReceivedInvocations.append(mediaSource)
if let getMediaContentMediaSourceClosure = getMediaContentMediaSourceClosure { if let getMediaContentMediaSourceClosure = getMediaContentMediaSourceClosure {
return try getMediaContentMediaSourceClosure(`mediaSource`) return try getMediaContentMediaSourceClosure(mediaSource)
} else { } else {
return getMediaContentMediaSourceReturnValue return getMediaContentMediaSourceReturnValue
} }
} }
//MARK: - `getMediaFile` //MARK: - getMediaFile
public var getMediaFileMediaSourceBodyMimeTypeTempDirThrowableError: Error? public var getMediaFileMediaSourceBodyMimeTypeTempDirThrowableError: Error?
public var getMediaFileMediaSourceBodyMimeTypeTempDirCallsCount = 0 public var getMediaFileMediaSourceBodyMimeTypeTempDirCallsCount = 0
public var getMediaFileMediaSourceBodyMimeTypeTempDirCalled: Bool { public var getMediaFileMediaSourceBodyMimeTypeTempDirCalled: Bool {
return getMediaFileMediaSourceBodyMimeTypeTempDirCallsCount > 0 return getMediaFileMediaSourceBodyMimeTypeTempDirCallsCount > 0
} }
public var getMediaFileMediaSourceBodyMimeTypeTempDirReceivedArguments: (`mediaSource`: MediaSource, `body`: String?, `mimeType`: String, `tempDir`: String?)? public var getMediaFileMediaSourceBodyMimeTypeTempDirReceivedArguments: (mediaSource: MediaSource, body: String?, mimeType: String, tempDir: String?)?
public var getMediaFileMediaSourceBodyMimeTypeTempDirReceivedInvocations: [(`mediaSource`: MediaSource, `body`: String?, `mimeType`: String, `tempDir`: String?)] = [] public var getMediaFileMediaSourceBodyMimeTypeTempDirReceivedInvocations: [(mediaSource: MediaSource, body: String?, mimeType: String, tempDir: String?)] = []
public var getMediaFileMediaSourceBodyMimeTypeTempDirReturnValue: MediaFileHandle! public var getMediaFileMediaSourceBodyMimeTypeTempDirReturnValue: MediaFileHandle!
public var getMediaFileMediaSourceBodyMimeTypeTempDirClosure: ((MediaSource, String?, String, String?) throws -> MediaFileHandle)? public var getMediaFileMediaSourceBodyMimeTypeTempDirClosure: ((MediaSource, String?, String, String?) throws -> MediaFileHandle)?
public func `getMediaFile`(`mediaSource`: MediaSource, `body`: String?, `mimeType`: String, `tempDir`: String?) throws -> MediaFileHandle { public func getMediaFile(mediaSource: MediaSource, body: String?, mimeType: String, tempDir: String?) throws -> MediaFileHandle {
if let error = getMediaFileMediaSourceBodyMimeTypeTempDirThrowableError { if let error = getMediaFileMediaSourceBodyMimeTypeTempDirThrowableError {
throw error throw error
} }
@@ -227,24 +227,24 @@ class SDKClientMock: SDKClientProtocol {
getMediaFileMediaSourceBodyMimeTypeTempDirReceivedArguments = (mediaSource: mediaSource, body: body, mimeType: mimeType, tempDir: tempDir) getMediaFileMediaSourceBodyMimeTypeTempDirReceivedArguments = (mediaSource: mediaSource, body: body, mimeType: mimeType, tempDir: tempDir)
getMediaFileMediaSourceBodyMimeTypeTempDirReceivedInvocations.append((mediaSource: mediaSource, body: body, mimeType: mimeType, tempDir: tempDir)) getMediaFileMediaSourceBodyMimeTypeTempDirReceivedInvocations.append((mediaSource: mediaSource, body: body, mimeType: mimeType, tempDir: tempDir))
if let getMediaFileMediaSourceBodyMimeTypeTempDirClosure = getMediaFileMediaSourceBodyMimeTypeTempDirClosure { if let getMediaFileMediaSourceBodyMimeTypeTempDirClosure = getMediaFileMediaSourceBodyMimeTypeTempDirClosure {
return try getMediaFileMediaSourceBodyMimeTypeTempDirClosure(`mediaSource`, `body`, `mimeType`, `tempDir`) return try getMediaFileMediaSourceBodyMimeTypeTempDirClosure(mediaSource, body, mimeType, tempDir)
} else { } else {
return getMediaFileMediaSourceBodyMimeTypeTempDirReturnValue return getMediaFileMediaSourceBodyMimeTypeTempDirReturnValue
} }
} }
//MARK: - `getMediaThumbnail` //MARK: - getMediaThumbnail
public var getMediaThumbnailMediaSourceWidthHeightThrowableError: Error? public var getMediaThumbnailMediaSourceWidthHeightThrowableError: Error?
public var getMediaThumbnailMediaSourceWidthHeightCallsCount = 0 public var getMediaThumbnailMediaSourceWidthHeightCallsCount = 0
public var getMediaThumbnailMediaSourceWidthHeightCalled: Bool { public var getMediaThumbnailMediaSourceWidthHeightCalled: Bool {
return getMediaThumbnailMediaSourceWidthHeightCallsCount > 0 return getMediaThumbnailMediaSourceWidthHeightCallsCount > 0
} }
public var getMediaThumbnailMediaSourceWidthHeightReceivedArguments: (`mediaSource`: MediaSource, `width`: UInt64, `height`: UInt64)? public var getMediaThumbnailMediaSourceWidthHeightReceivedArguments: (mediaSource: MediaSource, width: UInt64, height: UInt64)?
public var getMediaThumbnailMediaSourceWidthHeightReceivedInvocations: [(`mediaSource`: MediaSource, `width`: UInt64, `height`: UInt64)] = [] public var getMediaThumbnailMediaSourceWidthHeightReceivedInvocations: [(mediaSource: MediaSource, width: UInt64, height: UInt64)] = []
public var getMediaThumbnailMediaSourceWidthHeightReturnValue: [UInt8]! public var getMediaThumbnailMediaSourceWidthHeightReturnValue: [UInt8]!
public var getMediaThumbnailMediaSourceWidthHeightClosure: ((MediaSource, UInt64, UInt64) throws -> [UInt8])? public var getMediaThumbnailMediaSourceWidthHeightClosure: ((MediaSource, UInt64, UInt64) throws -> [UInt8])?
public func `getMediaThumbnail`(`mediaSource`: MediaSource, `width`: UInt64, `height`: UInt64) throws -> [UInt8] { public func getMediaThumbnail(mediaSource: MediaSource, width: UInt64, height: UInt64) throws -> [UInt8] {
if let error = getMediaThumbnailMediaSourceWidthHeightThrowableError { if let error = getMediaThumbnailMediaSourceWidthHeightThrowableError {
throw error throw error
} }
@@ -252,12 +252,12 @@ class SDKClientMock: SDKClientProtocol {
getMediaThumbnailMediaSourceWidthHeightReceivedArguments = (mediaSource: mediaSource, width: width, height: height) getMediaThumbnailMediaSourceWidthHeightReceivedArguments = (mediaSource: mediaSource, width: width, height: height)
getMediaThumbnailMediaSourceWidthHeightReceivedInvocations.append((mediaSource: mediaSource, width: width, height: height)) getMediaThumbnailMediaSourceWidthHeightReceivedInvocations.append((mediaSource: mediaSource, width: width, height: height))
if let getMediaThumbnailMediaSourceWidthHeightClosure = getMediaThumbnailMediaSourceWidthHeightClosure { if let getMediaThumbnailMediaSourceWidthHeightClosure = getMediaThumbnailMediaSourceWidthHeightClosure {
return try getMediaThumbnailMediaSourceWidthHeightClosure(`mediaSource`, `width`, `height`) return try getMediaThumbnailMediaSourceWidthHeightClosure(mediaSource, width, height)
} else { } else {
return getMediaThumbnailMediaSourceWidthHeightReturnValue return getMediaThumbnailMediaSourceWidthHeightReturnValue
} }
} }
//MARK: - `getNotificationSettings` //MARK: - getNotificationSettings
public var getNotificationSettingsCallsCount = 0 public var getNotificationSettingsCallsCount = 0
public var getNotificationSettingsCalled: Bool { public var getNotificationSettingsCalled: Bool {
@@ -266,7 +266,7 @@ class SDKClientMock: SDKClientProtocol {
public var getNotificationSettingsReturnValue: NotificationSettings! public var getNotificationSettingsReturnValue: NotificationSettings!
public var getNotificationSettingsClosure: (() -> NotificationSettings)? public var getNotificationSettingsClosure: (() -> NotificationSettings)?
public func `getNotificationSettings`() -> NotificationSettings { public func getNotificationSettings() -> NotificationSettings {
getNotificationSettingsCallsCount += 1 getNotificationSettingsCallsCount += 1
if let getNotificationSettingsClosure = getNotificationSettingsClosure { if let getNotificationSettingsClosure = getNotificationSettingsClosure {
return getNotificationSettingsClosure() return getNotificationSettingsClosure()
@@ -274,7 +274,7 @@ class SDKClientMock: SDKClientProtocol {
return getNotificationSettingsReturnValue return getNotificationSettingsReturnValue
} }
} }
//MARK: - `getProfile` //MARK: - getProfile
public var getProfileUserIdThrowableError: Error? public var getProfileUserIdThrowableError: Error?
public var getProfileUserIdCallsCount = 0 public var getProfileUserIdCallsCount = 0
@@ -286,20 +286,20 @@ class SDKClientMock: SDKClientProtocol {
public var getProfileUserIdReturnValue: UserProfile! public var getProfileUserIdReturnValue: UserProfile!
public var getProfileUserIdClosure: ((String) throws -> UserProfile)? public var getProfileUserIdClosure: ((String) throws -> UserProfile)?
public func `getProfile`(`userId`: String) throws -> UserProfile { public func getProfile(userId: String) throws -> UserProfile {
if let error = getProfileUserIdThrowableError { if let error = getProfileUserIdThrowableError {
throw error throw error
} }
getProfileUserIdCallsCount += 1 getProfileUserIdCallsCount += 1
getProfileUserIdReceivedUserId = userId getProfileUserIdReceivedUserId = userId
getProfileUserIdReceivedInvocations.append(`userId`) getProfileUserIdReceivedInvocations.append(userId)
if let getProfileUserIdClosure = getProfileUserIdClosure { if let getProfileUserIdClosure = getProfileUserIdClosure {
return try getProfileUserIdClosure(`userId`) return try getProfileUserIdClosure(userId)
} else { } else {
return getProfileUserIdReturnValue return getProfileUserIdReturnValue
} }
} }
//MARK: - `getSessionVerificationController` //MARK: - getSessionVerificationController
public var getSessionVerificationControllerThrowableError: Error? public var getSessionVerificationControllerThrowableError: Error?
public var getSessionVerificationControllerCallsCount = 0 public var getSessionVerificationControllerCallsCount = 0
@@ -309,7 +309,7 @@ class SDKClientMock: SDKClientProtocol {
public var getSessionVerificationControllerReturnValue: SessionVerificationController! public var getSessionVerificationControllerReturnValue: SessionVerificationController!
public var getSessionVerificationControllerClosure: (() throws -> SessionVerificationController)? public var getSessionVerificationControllerClosure: (() throws -> SessionVerificationController)?
public func `getSessionVerificationController`() throws -> SessionVerificationController { public func getSessionVerificationController() throws -> SessionVerificationController {
if let error = getSessionVerificationControllerThrowableError { if let error = getSessionVerificationControllerThrowableError {
throw error throw error
} }
@@ -320,7 +320,7 @@ class SDKClientMock: SDKClientProtocol {
return getSessionVerificationControllerReturnValue return getSessionVerificationControllerReturnValue
} }
} }
//MARK: - `homeserver` //MARK: - homeserver
public var homeserverCallsCount = 0 public var homeserverCallsCount = 0
public var homeserverCalled: Bool { public var homeserverCalled: Bool {
@@ -329,7 +329,7 @@ class SDKClientMock: SDKClientProtocol {
public var homeserverReturnValue: String! public var homeserverReturnValue: String!
public var homeserverClosure: (() -> String)? public var homeserverClosure: (() -> String)?
public func `homeserver`() -> String { public func homeserver() -> String {
homeserverCallsCount += 1 homeserverCallsCount += 1
if let homeserverClosure = homeserverClosure { if let homeserverClosure = homeserverClosure {
return homeserverClosure() return homeserverClosure()
@@ -337,7 +337,7 @@ class SDKClientMock: SDKClientProtocol {
return homeserverReturnValue return homeserverReturnValue
} }
} }
//MARK: - `ignoreUser` //MARK: - ignoreUser
public var ignoreUserUserIdThrowableError: Error? public var ignoreUserUserIdThrowableError: Error?
public var ignoreUserUserIdCallsCount = 0 public var ignoreUserUserIdCallsCount = 0
@@ -348,36 +348,36 @@ class SDKClientMock: SDKClientProtocol {
public var ignoreUserUserIdReceivedInvocations: [String] = [] public var ignoreUserUserIdReceivedInvocations: [String] = []
public var ignoreUserUserIdClosure: ((String) throws -> Void)? public var ignoreUserUserIdClosure: ((String) throws -> Void)?
public func `ignoreUser`(`userId`: String) throws { public func ignoreUser(userId: String) throws {
if let error = ignoreUserUserIdThrowableError { if let error = ignoreUserUserIdThrowableError {
throw error throw error
} }
ignoreUserUserIdCallsCount += 1 ignoreUserUserIdCallsCount += 1
ignoreUserUserIdReceivedUserId = userId ignoreUserUserIdReceivedUserId = userId
ignoreUserUserIdReceivedInvocations.append(`userId`) ignoreUserUserIdReceivedInvocations.append(userId)
try ignoreUserUserIdClosure?(`userId`) try ignoreUserUserIdClosure?(userId)
} }
//MARK: - `login` //MARK: - login
public var loginUsernamePasswordInitialDeviceNameDeviceIdThrowableError: Error? public var loginUsernamePasswordInitialDeviceNameDeviceIdThrowableError: Error?
public var loginUsernamePasswordInitialDeviceNameDeviceIdCallsCount = 0 public var loginUsernamePasswordInitialDeviceNameDeviceIdCallsCount = 0
public var loginUsernamePasswordInitialDeviceNameDeviceIdCalled: Bool { public var loginUsernamePasswordInitialDeviceNameDeviceIdCalled: Bool {
return loginUsernamePasswordInitialDeviceNameDeviceIdCallsCount > 0 return loginUsernamePasswordInitialDeviceNameDeviceIdCallsCount > 0
} }
public var loginUsernamePasswordInitialDeviceNameDeviceIdReceivedArguments: (`username`: String, `password`: String, `initialDeviceName`: String?, `deviceId`: String?)? public var loginUsernamePasswordInitialDeviceNameDeviceIdReceivedArguments: (username: String, password: String, initialDeviceName: String?, deviceId: String?)?
public var loginUsernamePasswordInitialDeviceNameDeviceIdReceivedInvocations: [(`username`: String, `password`: String, `initialDeviceName`: String?, `deviceId`: String?)] = [] public var loginUsernamePasswordInitialDeviceNameDeviceIdReceivedInvocations: [(username: String, password: String, initialDeviceName: String?, deviceId: String?)] = []
public var loginUsernamePasswordInitialDeviceNameDeviceIdClosure: ((String, String, String?, String?) throws -> Void)? public var loginUsernamePasswordInitialDeviceNameDeviceIdClosure: ((String, String, String?, String?) throws -> Void)?
public func `login`(`username`: String, `password`: String, `initialDeviceName`: String?, `deviceId`: String?) throws { public func login(username: String, password: String, initialDeviceName: String?, deviceId: String?) throws {
if let error = loginUsernamePasswordInitialDeviceNameDeviceIdThrowableError { if let error = loginUsernamePasswordInitialDeviceNameDeviceIdThrowableError {
throw error throw error
} }
loginUsernamePasswordInitialDeviceNameDeviceIdCallsCount += 1 loginUsernamePasswordInitialDeviceNameDeviceIdCallsCount += 1
loginUsernamePasswordInitialDeviceNameDeviceIdReceivedArguments = (username: username, password: password, initialDeviceName: initialDeviceName, deviceId: deviceId) loginUsernamePasswordInitialDeviceNameDeviceIdReceivedArguments = (username: username, password: password, initialDeviceName: initialDeviceName, deviceId: deviceId)
loginUsernamePasswordInitialDeviceNameDeviceIdReceivedInvocations.append((username: username, password: password, initialDeviceName: initialDeviceName, deviceId: deviceId)) loginUsernamePasswordInitialDeviceNameDeviceIdReceivedInvocations.append((username: username, password: password, initialDeviceName: initialDeviceName, deviceId: deviceId))
try loginUsernamePasswordInitialDeviceNameDeviceIdClosure?(`username`, `password`, `initialDeviceName`, `deviceId`) try loginUsernamePasswordInitialDeviceNameDeviceIdClosure?(username, password, initialDeviceName, deviceId)
} }
//MARK: - `logout` //MARK: - logout
public var logoutThrowableError: Error? public var logoutThrowableError: Error?
public var logoutCallsCount = 0 public var logoutCallsCount = 0
@@ -387,7 +387,7 @@ class SDKClientMock: SDKClientProtocol {
public var logoutReturnValue: String? public var logoutReturnValue: String?
public var logoutClosure: (() throws -> String?)? public var logoutClosure: (() throws -> String?)?
public func `logout`() throws -> String? { public func logout() throws -> String? {
if let error = logoutThrowableError { if let error = logoutThrowableError {
throw error throw error
} }
@@ -398,7 +398,7 @@ class SDKClientMock: SDKClientProtocol {
return logoutReturnValue return logoutReturnValue
} }
} }
//MARK: - `notificationClient` //MARK: - notificationClient
public var notificationClientThrowableError: Error? public var notificationClientThrowableError: Error?
public var notificationClientCallsCount = 0 public var notificationClientCallsCount = 0
@@ -408,7 +408,7 @@ class SDKClientMock: SDKClientProtocol {
public var notificationClientReturnValue: NotificationClientBuilder! public var notificationClientReturnValue: NotificationClientBuilder!
public var notificationClientClosure: (() throws -> NotificationClientBuilder)? public var notificationClientClosure: (() throws -> NotificationClientBuilder)?
public func `notificationClient`() throws -> NotificationClientBuilder { public func notificationClient() throws -> NotificationClientBuilder {
if let error = notificationClientThrowableError { if let error = notificationClientThrowableError {
throw error throw error
} }
@@ -419,7 +419,7 @@ class SDKClientMock: SDKClientProtocol {
return notificationClientReturnValue return notificationClientReturnValue
} }
} }
//MARK: - `restoreSession` //MARK: - restoreSession
public var restoreSessionSessionThrowableError: Error? public var restoreSessionSessionThrowableError: Error?
public var restoreSessionSessionCallsCount = 0 public var restoreSessionSessionCallsCount = 0
@@ -430,16 +430,16 @@ class SDKClientMock: SDKClientProtocol {
public var restoreSessionSessionReceivedInvocations: [Session] = [] public var restoreSessionSessionReceivedInvocations: [Session] = []
public var restoreSessionSessionClosure: ((Session) throws -> Void)? public var restoreSessionSessionClosure: ((Session) throws -> Void)?
public func `restoreSession`(`session`: Session) throws { public func restoreSession(session: Session) throws {
if let error = restoreSessionSessionThrowableError { if let error = restoreSessionSessionThrowableError {
throw error throw error
} }
restoreSessionSessionCallsCount += 1 restoreSessionSessionCallsCount += 1
restoreSessionSessionReceivedSession = session restoreSessionSessionReceivedSession = session
restoreSessionSessionReceivedInvocations.append(`session`) restoreSessionSessionReceivedInvocations.append(session)
try restoreSessionSessionClosure?(`session`) try restoreSessionSessionClosure?(session)
} }
//MARK: - `rooms` //MARK: - rooms
public var roomsCallsCount = 0 public var roomsCallsCount = 0
public var roomsCalled: Bool { public var roomsCalled: Bool {
@@ -448,7 +448,7 @@ class SDKClientMock: SDKClientProtocol {
public var roomsReturnValue: [Room]! public var roomsReturnValue: [Room]!
public var roomsClosure: (() -> [Room])? public var roomsClosure: (() -> [Room])?
public func `rooms`() -> [Room] { public func rooms() -> [Room] {
roomsCallsCount += 1 roomsCallsCount += 1
if let roomsClosure = roomsClosure { if let roomsClosure = roomsClosure {
return roomsClosure() return roomsClosure()
@@ -456,19 +456,19 @@ class SDKClientMock: SDKClientProtocol {
return roomsReturnValue return roomsReturnValue
} }
} }
//MARK: - `searchUsers` //MARK: - searchUsers
public var searchUsersSearchTermLimitThrowableError: Error? public var searchUsersSearchTermLimitThrowableError: Error?
public var searchUsersSearchTermLimitCallsCount = 0 public var searchUsersSearchTermLimitCallsCount = 0
public var searchUsersSearchTermLimitCalled: Bool { public var searchUsersSearchTermLimitCalled: Bool {
return searchUsersSearchTermLimitCallsCount > 0 return searchUsersSearchTermLimitCallsCount > 0
} }
public var searchUsersSearchTermLimitReceivedArguments: (`searchTerm`: String, `limit`: UInt64)? public var searchUsersSearchTermLimitReceivedArguments: (searchTerm: String, limit: UInt64)?
public var searchUsersSearchTermLimitReceivedInvocations: [(`searchTerm`: String, `limit`: UInt64)] = [] public var searchUsersSearchTermLimitReceivedInvocations: [(searchTerm: String, limit: UInt64)] = []
public var searchUsersSearchTermLimitReturnValue: SearchUsersResults! public var searchUsersSearchTermLimitReturnValue: SearchUsersResults!
public var searchUsersSearchTermLimitClosure: ((String, UInt64) throws -> SearchUsersResults)? public var searchUsersSearchTermLimitClosure: ((String, UInt64) throws -> SearchUsersResults)?
public func `searchUsers`(`searchTerm`: String, `limit`: UInt64) throws -> SearchUsersResults { public func searchUsers(searchTerm: String, limit: UInt64) throws -> SearchUsersResults {
if let error = searchUsersSearchTermLimitThrowableError { if let error = searchUsersSearchTermLimitThrowableError {
throw error throw error
} }
@@ -476,12 +476,12 @@ class SDKClientMock: SDKClientProtocol {
searchUsersSearchTermLimitReceivedArguments = (searchTerm: searchTerm, limit: limit) searchUsersSearchTermLimitReceivedArguments = (searchTerm: searchTerm, limit: limit)
searchUsersSearchTermLimitReceivedInvocations.append((searchTerm: searchTerm, limit: limit)) searchUsersSearchTermLimitReceivedInvocations.append((searchTerm: searchTerm, limit: limit))
if let searchUsersSearchTermLimitClosure = searchUsersSearchTermLimitClosure { if let searchUsersSearchTermLimitClosure = searchUsersSearchTermLimitClosure {
return try searchUsersSearchTermLimitClosure(`searchTerm`, `limit`) return try searchUsersSearchTermLimitClosure(searchTerm, limit)
} else { } else {
return searchUsersSearchTermLimitReturnValue return searchUsersSearchTermLimitReturnValue
} }
} }
//MARK: - `session` //MARK: - session
public var sessionThrowableError: Error? public var sessionThrowableError: Error?
public var sessionCallsCount = 0 public var sessionCallsCount = 0
@@ -491,7 +491,7 @@ class SDKClientMock: SDKClientProtocol {
public var sessionReturnValue: Session! public var sessionReturnValue: Session!
public var sessionClosure: (() throws -> Session)? public var sessionClosure: (() throws -> Session)?
public func `session`() throws -> Session { public func session() throws -> Session {
if let error = sessionThrowableError { if let error = sessionThrowableError {
throw error throw error
} }
@@ -502,27 +502,27 @@ class SDKClientMock: SDKClientProtocol {
return sessionReturnValue return sessionReturnValue
} }
} }
//MARK: - `setAccountData` //MARK: - setAccountData
public var setAccountDataEventTypeContentThrowableError: Error? public var setAccountDataEventTypeContentThrowableError: Error?
public var setAccountDataEventTypeContentCallsCount = 0 public var setAccountDataEventTypeContentCallsCount = 0
public var setAccountDataEventTypeContentCalled: Bool { public var setAccountDataEventTypeContentCalled: Bool {
return setAccountDataEventTypeContentCallsCount > 0 return setAccountDataEventTypeContentCallsCount > 0
} }
public var setAccountDataEventTypeContentReceivedArguments: (`eventType`: String, `content`: String)? public var setAccountDataEventTypeContentReceivedArguments: (eventType: String, content: String)?
public var setAccountDataEventTypeContentReceivedInvocations: [(`eventType`: String, `content`: String)] = [] public var setAccountDataEventTypeContentReceivedInvocations: [(eventType: String, content: String)] = []
public var setAccountDataEventTypeContentClosure: ((String, String) throws -> Void)? public var setAccountDataEventTypeContentClosure: ((String, String) throws -> Void)?
public func `setAccountData`(`eventType`: String, `content`: String) throws { public func setAccountData(eventType: String, content: String) throws {
if let error = setAccountDataEventTypeContentThrowableError { if let error = setAccountDataEventTypeContentThrowableError {
throw error throw error
} }
setAccountDataEventTypeContentCallsCount += 1 setAccountDataEventTypeContentCallsCount += 1
setAccountDataEventTypeContentReceivedArguments = (eventType: eventType, content: content) setAccountDataEventTypeContentReceivedArguments = (eventType: eventType, content: content)
setAccountDataEventTypeContentReceivedInvocations.append((eventType: eventType, content: content)) setAccountDataEventTypeContentReceivedInvocations.append((eventType: eventType, content: content))
try setAccountDataEventTypeContentClosure?(`eventType`, `content`) try setAccountDataEventTypeContentClosure?(eventType, content)
} }
//MARK: - `setDelegate` //MARK: - setDelegate
public var setDelegateDelegateCallsCount = 0 public var setDelegateDelegateCallsCount = 0
public var setDelegateDelegateCalled: Bool { public var setDelegateDelegateCalled: Bool {
@@ -532,13 +532,13 @@ class SDKClientMock: SDKClientProtocol {
public var setDelegateDelegateReceivedInvocations: [ClientDelegate?] = [] public var setDelegateDelegateReceivedInvocations: [ClientDelegate?] = []
public var setDelegateDelegateClosure: ((ClientDelegate?) -> Void)? public var setDelegateDelegateClosure: ((ClientDelegate?) -> Void)?
public func `setDelegate`(`delegate`: ClientDelegate?) { public func setDelegate(delegate: ClientDelegate?) {
setDelegateDelegateCallsCount += 1 setDelegateDelegateCallsCount += 1
setDelegateDelegateReceivedDelegate = delegate setDelegateDelegateReceivedDelegate = delegate
setDelegateDelegateReceivedInvocations.append(`delegate`) setDelegateDelegateReceivedInvocations.append(delegate)
setDelegateDelegateClosure?(`delegate`) setDelegateDelegateClosure?(delegate)
} }
//MARK: - `setDisplayName` //MARK: - setDisplayName
public var setDisplayNameNameThrowableError: Error? public var setDisplayNameNameThrowableError: Error?
public var setDisplayNameNameCallsCount = 0 public var setDisplayNameNameCallsCount = 0
@@ -549,36 +549,36 @@ class SDKClientMock: SDKClientProtocol {
public var setDisplayNameNameReceivedInvocations: [String] = [] public var setDisplayNameNameReceivedInvocations: [String] = []
public var setDisplayNameNameClosure: ((String) throws -> Void)? public var setDisplayNameNameClosure: ((String) throws -> Void)?
public func `setDisplayName`(`name`: String) throws { public func setDisplayName(name: String) throws {
if let error = setDisplayNameNameThrowableError { if let error = setDisplayNameNameThrowableError {
throw error throw error
} }
setDisplayNameNameCallsCount += 1 setDisplayNameNameCallsCount += 1
setDisplayNameNameReceivedName = name setDisplayNameNameReceivedName = name
setDisplayNameNameReceivedInvocations.append(`name`) setDisplayNameNameReceivedInvocations.append(name)
try setDisplayNameNameClosure?(`name`) try setDisplayNameNameClosure?(name)
} }
//MARK: - `setPusher` //MARK: - setPusher
public var setPusherIdentifiersKindAppDisplayNameDeviceDisplayNameProfileTagLangThrowableError: Error? public var setPusherIdentifiersKindAppDisplayNameDeviceDisplayNameProfileTagLangThrowableError: Error?
public var setPusherIdentifiersKindAppDisplayNameDeviceDisplayNameProfileTagLangCallsCount = 0 public var setPusherIdentifiersKindAppDisplayNameDeviceDisplayNameProfileTagLangCallsCount = 0
public var setPusherIdentifiersKindAppDisplayNameDeviceDisplayNameProfileTagLangCalled: Bool { public var setPusherIdentifiersKindAppDisplayNameDeviceDisplayNameProfileTagLangCalled: Bool {
return setPusherIdentifiersKindAppDisplayNameDeviceDisplayNameProfileTagLangCallsCount > 0 return setPusherIdentifiersKindAppDisplayNameDeviceDisplayNameProfileTagLangCallsCount > 0
} }
public var setPusherIdentifiersKindAppDisplayNameDeviceDisplayNameProfileTagLangReceivedArguments: (`identifiers`: PusherIdentifiers, `kind`: PusherKind, `appDisplayName`: String, `deviceDisplayName`: String, `profileTag`: String?, `lang`: String)? public var setPusherIdentifiersKindAppDisplayNameDeviceDisplayNameProfileTagLangReceivedArguments: (identifiers: PusherIdentifiers, kind: PusherKind, appDisplayName: String, deviceDisplayName: String, profileTag: String?, lang: String)?
public var setPusherIdentifiersKindAppDisplayNameDeviceDisplayNameProfileTagLangReceivedInvocations: [(`identifiers`: PusherIdentifiers, `kind`: PusherKind, `appDisplayName`: String, `deviceDisplayName`: String, `profileTag`: String?, `lang`: String)] = [] public var setPusherIdentifiersKindAppDisplayNameDeviceDisplayNameProfileTagLangReceivedInvocations: [(identifiers: PusherIdentifiers, kind: PusherKind, appDisplayName: String, deviceDisplayName: String, profileTag: String?, lang: String)] = []
public var setPusherIdentifiersKindAppDisplayNameDeviceDisplayNameProfileTagLangClosure: ((PusherIdentifiers, PusherKind, String, String, String?, String) throws -> Void)? public var setPusherIdentifiersKindAppDisplayNameDeviceDisplayNameProfileTagLangClosure: ((PusherIdentifiers, PusherKind, String, String, String?, String) throws -> Void)?
public func `setPusher`(`identifiers`: PusherIdentifiers, `kind`: PusherKind, `appDisplayName`: String, `deviceDisplayName`: String, `profileTag`: String?, `lang`: String) throws { public func setPusher(identifiers: PusherIdentifiers, kind: PusherKind, appDisplayName: String, deviceDisplayName: String, profileTag: String?, lang: String) throws {
if let error = setPusherIdentifiersKindAppDisplayNameDeviceDisplayNameProfileTagLangThrowableError { if let error = setPusherIdentifiersKindAppDisplayNameDeviceDisplayNameProfileTagLangThrowableError {
throw error throw error
} }
setPusherIdentifiersKindAppDisplayNameDeviceDisplayNameProfileTagLangCallsCount += 1 setPusherIdentifiersKindAppDisplayNameDeviceDisplayNameProfileTagLangCallsCount += 1
setPusherIdentifiersKindAppDisplayNameDeviceDisplayNameProfileTagLangReceivedArguments = (identifiers: identifiers, kind: kind, appDisplayName: appDisplayName, deviceDisplayName: deviceDisplayName, profileTag: profileTag, lang: lang) setPusherIdentifiersKindAppDisplayNameDeviceDisplayNameProfileTagLangReceivedArguments = (identifiers: identifiers, kind: kind, appDisplayName: appDisplayName, deviceDisplayName: deviceDisplayName, profileTag: profileTag, lang: lang)
setPusherIdentifiersKindAppDisplayNameDeviceDisplayNameProfileTagLangReceivedInvocations.append((identifiers: identifiers, kind: kind, appDisplayName: appDisplayName, deviceDisplayName: deviceDisplayName, profileTag: profileTag, lang: lang)) setPusherIdentifiersKindAppDisplayNameDeviceDisplayNameProfileTagLangReceivedInvocations.append((identifiers: identifiers, kind: kind, appDisplayName: appDisplayName, deviceDisplayName: deviceDisplayName, profileTag: profileTag, lang: lang))
try setPusherIdentifiersKindAppDisplayNameDeviceDisplayNameProfileTagLangClosure?(`identifiers`, `kind`, `appDisplayName`, `deviceDisplayName`, `profileTag`, `lang`) try setPusherIdentifiersKindAppDisplayNameDeviceDisplayNameProfileTagLangClosure?(identifiers, kind, appDisplayName, deviceDisplayName, profileTag, lang)
} }
//MARK: - `syncService` //MARK: - syncService
public var syncServiceCallsCount = 0 public var syncServiceCallsCount = 0
public var syncServiceCalled: Bool { public var syncServiceCalled: Bool {
@@ -587,7 +587,7 @@ class SDKClientMock: SDKClientProtocol {
public var syncServiceReturnValue: SyncServiceBuilder! public var syncServiceReturnValue: SyncServiceBuilder!
public var syncServiceClosure: (() -> SyncServiceBuilder)? public var syncServiceClosure: (() -> SyncServiceBuilder)?
public func `syncService`() -> SyncServiceBuilder { public func syncService() -> SyncServiceBuilder {
syncServiceCallsCount += 1 syncServiceCallsCount += 1
if let syncServiceClosure = syncServiceClosure { if let syncServiceClosure = syncServiceClosure {
return syncServiceClosure() return syncServiceClosure()
@@ -595,7 +595,7 @@ class SDKClientMock: SDKClientProtocol {
return syncServiceReturnValue return syncServiceReturnValue
} }
} }
//MARK: - `unignoreUser` //MARK: - unignoreUser
public var unignoreUserUserIdThrowableError: Error? public var unignoreUserUserIdThrowableError: Error?
public var unignoreUserUserIdCallsCount = 0 public var unignoreUserUserIdCallsCount = 0
@@ -606,28 +606,28 @@ class SDKClientMock: SDKClientProtocol {
public var unignoreUserUserIdReceivedInvocations: [String] = [] public var unignoreUserUserIdReceivedInvocations: [String] = []
public var unignoreUserUserIdClosure: ((String) throws -> Void)? public var unignoreUserUserIdClosure: ((String) throws -> Void)?
public func `unignoreUser`(`userId`: String) throws { public func unignoreUser(userId: String) throws {
if let error = unignoreUserUserIdThrowableError { if let error = unignoreUserUserIdThrowableError {
throw error throw error
} }
unignoreUserUserIdCallsCount += 1 unignoreUserUserIdCallsCount += 1
unignoreUserUserIdReceivedUserId = userId unignoreUserUserIdReceivedUserId = userId
unignoreUserUserIdReceivedInvocations.append(`userId`) unignoreUserUserIdReceivedInvocations.append(userId)
try unignoreUserUserIdClosure?(`userId`) try unignoreUserUserIdClosure?(userId)
} }
//MARK: - `uploadMedia` //MARK: - uploadMedia
public var uploadMediaMimeTypeDataProgressWatcherThrowableError: Error? public var uploadMediaMimeTypeDataProgressWatcherThrowableError: Error?
public var uploadMediaMimeTypeDataProgressWatcherCallsCount = 0 public var uploadMediaMimeTypeDataProgressWatcherCallsCount = 0
public var uploadMediaMimeTypeDataProgressWatcherCalled: Bool { public var uploadMediaMimeTypeDataProgressWatcherCalled: Bool {
return uploadMediaMimeTypeDataProgressWatcherCallsCount > 0 return uploadMediaMimeTypeDataProgressWatcherCallsCount > 0
} }
public var uploadMediaMimeTypeDataProgressWatcherReceivedArguments: (`mimeType`: String, `data`: [UInt8], `progressWatcher`: ProgressWatcher?)? public var uploadMediaMimeTypeDataProgressWatcherReceivedArguments: (mimeType: String, data: [UInt8], progressWatcher: ProgressWatcher?)?
public var uploadMediaMimeTypeDataProgressWatcherReceivedInvocations: [(`mimeType`: String, `data`: [UInt8], `progressWatcher`: ProgressWatcher?)] = [] public var uploadMediaMimeTypeDataProgressWatcherReceivedInvocations: [(mimeType: String, data: [UInt8], progressWatcher: ProgressWatcher?)] = []
public var uploadMediaMimeTypeDataProgressWatcherReturnValue: String! public var uploadMediaMimeTypeDataProgressWatcherReturnValue: String!
public var uploadMediaMimeTypeDataProgressWatcherClosure: ((String, [UInt8], ProgressWatcher?) throws -> String)? public var uploadMediaMimeTypeDataProgressWatcherClosure: ((String, [UInt8], ProgressWatcher?) throws -> String)?
public func `uploadMedia`(`mimeType`: String, `data`: [UInt8], `progressWatcher`: ProgressWatcher?) throws -> String { public func uploadMedia(mimeType: String, data: [UInt8], progressWatcher: ProgressWatcher?) throws -> String {
if let error = uploadMediaMimeTypeDataProgressWatcherThrowableError { if let error = uploadMediaMimeTypeDataProgressWatcherThrowableError {
throw error throw error
} }
@@ -635,12 +635,12 @@ class SDKClientMock: SDKClientProtocol {
uploadMediaMimeTypeDataProgressWatcherReceivedArguments = (mimeType: mimeType, data: data, progressWatcher: progressWatcher) uploadMediaMimeTypeDataProgressWatcherReceivedArguments = (mimeType: mimeType, data: data, progressWatcher: progressWatcher)
uploadMediaMimeTypeDataProgressWatcherReceivedInvocations.append((mimeType: mimeType, data: data, progressWatcher: progressWatcher)) uploadMediaMimeTypeDataProgressWatcherReceivedInvocations.append((mimeType: mimeType, data: data, progressWatcher: progressWatcher))
if let uploadMediaMimeTypeDataProgressWatcherClosure = uploadMediaMimeTypeDataProgressWatcherClosure { if let uploadMediaMimeTypeDataProgressWatcherClosure = uploadMediaMimeTypeDataProgressWatcherClosure {
return try uploadMediaMimeTypeDataProgressWatcherClosure(`mimeType`, `data`, `progressWatcher`) return try uploadMediaMimeTypeDataProgressWatcherClosure(mimeType, data, progressWatcher)
} else { } else {
return uploadMediaMimeTypeDataProgressWatcherReturnValue return uploadMediaMimeTypeDataProgressWatcherReturnValue
} }
} }
//MARK: - `userId` //MARK: - userId
public var userIdThrowableError: Error? public var userIdThrowableError: Error?
public var userIdCallsCount = 0 public var userIdCallsCount = 0
@@ -650,7 +650,7 @@ class SDKClientMock: SDKClientProtocol {
public var userIdReturnValue: String! public var userIdReturnValue: String!
public var userIdClosure: (() throws -> String)? public var userIdClosure: (() throws -> String)?
public func `userId`() throws -> String { public func userId() throws -> String {
if let error = userIdThrowableError { if let error = userIdThrowableError {
throw error throw error
} }
+1 -1
View File
@@ -74,7 +74,7 @@ extension RoomProxyMock {
updateMembersClosure = { } updateMembersClosure = { }
acceptInvitationClosure = { .success(()) } acceptInvitationClosure = { .success(()) }
underlyingUpdatesPublisher = Empty(completeImmediately: false).eraseToAnyPublisher() underlyingStateUpdatesPublisher = Empty(completeImmediately: false).eraseToAnyPublisher()
setNameClosure = { _ in .success(()) } setNameClosure = { _ in .success(()) }
setTopicClosure = { _ in .success(()) } setTopicClosure = { _ in .success(()) }
getMemberUserIDReturnValue = .success(configuration.memberForID) getMemberUserIDReturnValue = .success(configuration.memberForID)
@@ -118,7 +118,7 @@ class RoomDetailsScreenViewModel: RoomDetailsScreenViewModelType, RoomDetailsScr
// MARK: - Private // MARK: - Private
private func setupRoomSubscription() { private func setupRoomSubscription() {
roomProxy.updatesPublisher roomProxy.stateUpdatesPublisher
.throttle(for: .milliseconds(200), scheduler: DispatchQueue.main, latest: true) .throttle(for: .milliseconds(200), scheduler: DispatchQueue.main, latest: true)
.sink { [weak self] _ in .sink { [weak self] _ in
guard let self else { return } guard let self else { return }
@@ -193,7 +193,7 @@ class RoomScreenViewModel: RoomScreenViewModelType, RoomScreenViewModelProtocol
.store(in: &cancellables) .store(in: &cancellables)
roomProxy roomProxy
.updatesPublisher .stateUpdatesPublisher
.throttle(for: .seconds(1), scheduler: DispatchQueue.main, latest: true) .throttle(for: .seconds(1), scheduler: DispatchQueue.main, latest: true)
.sink { [weak self] _ in .sink { [weak self] _ in
guard let self else { return } guard let self else { return }
+30 -5
View File
@@ -36,6 +36,7 @@ class RoomProxy: RoomProxyProtocol {
private var roomTimelineObservationToken: TaskHandle? private var roomTimelineObservationToken: TaskHandle?
private var backPaginationStateObservationToken: TaskHandle? private var backPaginationStateObservationToken: TaskHandle?
private var roomInfoObservationToken: TaskHandle?
private let backPaginationStateSubject = PassthroughSubject<BackPaginationStatus, Never>() private let backPaginationStateSubject = PassthroughSubject<BackPaginationStatus, Never>()
private let membersSubject = CurrentValueSubject<[RoomMemberProxyProtocol], Never>([]) private let membersSubject = CurrentValueSubject<[RoomMemberProxyProtocol], Never>([])
@@ -46,9 +47,12 @@ class RoomProxy: RoomProxyProtocol {
} }
private var timelineListener: RoomTimelineListener? private var timelineListener: RoomTimelineListener?
private let updatesSubject = PassthroughSubject<[TimelineDiff], Never>()
var updatesPublisher: AnyPublisher<[TimelineDiff], Never> { private let timelineUpdatesSubject = PassthroughSubject<[TimelineDiff], Never>()
updatesSubject.eraseToAnyPublisher()
private let stateUpdatesSubject = PassthroughSubject<Void, Never>()
var stateUpdatesPublisher: AnyPublisher<Void, Never> {
stateUpdatesSubject.eraseToAnyPublisher()
} }
var innerTimelineProvider: RoomTimelineProviderProtocol! var innerTimelineProvider: RoomTimelineProviderProtocol!
@@ -94,7 +98,7 @@ class RoomProxy: RoomProxyProtocol {
roomListItem.subscribe(settings: settings) roomListItem.subscribe(settings: settings)
let timelineListener = RoomTimelineListener { [weak self] timelineDiffs in let timelineListener = RoomTimelineListener { [weak self] timelineDiffs in
self?.updatesSubject.send(timelineDiffs) self?.timelineUpdatesSubject.send(timelineDiffs)
} }
self.timelineListener = timelineListener self.timelineListener = timelineListener
@@ -104,8 +108,10 @@ class RoomProxy: RoomProxyProtocol {
subscribeToBackpagination() subscribeToBackpagination()
subscribeToRoomStateUpdates()
innerTimelineProvider = await RoomTimelineProvider(currentItems: result.items, innerTimelineProvider = await RoomTimelineProvider(currentItems: result.items,
updatePublisher: updatesPublisher, updatePublisher: timelineUpdatesSubject.eraseToAnyPublisher(),
backPaginationStatePublisher: backPaginationStateSubject.eraseToAnyPublisher()) backPaginationStatePublisher: backPaginationStateSubject.eraseToAnyPublisher())
} }
@@ -697,6 +703,13 @@ class RoomProxy: RoomProxyProtocol {
MXLog.error("Failed to subscribe to back pagination state with error: \(error)") MXLog.error("Failed to subscribe to back pagination state with error: \(error)")
} }
} }
private func subscribeToRoomStateUpdates() {
roomInfoObservationToken = room.subscribeToRoomInfoUpdates(listener: RoomInfoUpdateListener { [weak self] in
MXLog.info("Received room info update")
self?.stateUpdatesSubject.send(())
})
}
} }
private final class RoomTimelineListener: TimelineListener { private final class RoomTimelineListener: TimelineListener {
@@ -736,3 +749,15 @@ private final class RoomBackpaginationStatusListener: BackPaginationStatusListen
onUpdateClosure(status) onUpdateClosure(status)
} }
} }
private final class RoomInfoUpdateListener: RoomInfoListener {
private let onUpdateClosure: () -> Void
init(_ onUpdateClosure: @escaping () -> Void) {
self.onUpdateClosure = onUpdateClosure
}
func call(roomInfo: RoomInfo) {
onUpdateClosure()
}
}
@@ -72,9 +72,9 @@ protocol RoomProxyProtocol {
var activeMembersCount: Int { get } var activeMembersCount: Int { get }
/// Publishes the room's updates. /// Publishes room state updates
/// The thread on which this publisher sends the output isn't defined. /// The thread on which this publisher sends the output isn't defined.
var updatesPublisher: AnyPublisher<[TimelineDiff], Never> { get } var stateUpdatesPublisher: AnyPublisher<Void, Never> { get }
var timelineProvider: RoomTimelineProviderProtocol { get } var timelineProvider: RoomTimelineProviderProtocol { get }