mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-03 06:55:59 +00:00
SDK Bump to 1.0.74 (#1059)
* testing improvements * code improvements and sdk bump * improved the stencil file * improved the build sdk function * code improvement * also added the tearDown
This commit is contained in:
@@ -207,8 +207,8 @@ class SDKClientMock: SDKClientProtocol {
|
||||
throw error
|
||||
}
|
||||
getMediaFileMediaSourceBodyMimeTypeTempDirCallsCount += 1
|
||||
getMediaFileMediaSourceBodyMimeTypeTempDirReceivedArguments = (`mediaSource`: `mediaSource`, `body`: `body`, `mimeType`: `mimeType`, `tempDir`: `tempDir`)
|
||||
getMediaFileMediaSourceBodyMimeTypeTempDirReceivedInvocations.append((`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))
|
||||
if let getMediaFileMediaSourceBodyMimeTypeTempDirClosure = getMediaFileMediaSourceBodyMimeTypeTempDirClosure {
|
||||
return try getMediaFileMediaSourceBodyMimeTypeTempDirClosure(`mediaSource`, `body`, `mimeType`, `tempDir`)
|
||||
} else {
|
||||
@@ -232,8 +232,8 @@ class SDKClientMock: SDKClientProtocol {
|
||||
throw error
|
||||
}
|
||||
getMediaThumbnailMediaSourceWidthHeightCallsCount += 1
|
||||
getMediaThumbnailMediaSourceWidthHeightReceivedArguments = (`mediaSource`: `mediaSource`, `width`: `width`, `height`: `height`)
|
||||
getMediaThumbnailMediaSourceWidthHeightReceivedInvocations.append((`mediaSource`: `mediaSource`, `width`: `width`, `height`: `height`))
|
||||
getMediaThumbnailMediaSourceWidthHeightReceivedArguments = (mediaSource: mediaSource, width: width, height: height)
|
||||
getMediaThumbnailMediaSourceWidthHeightReceivedInvocations.append((mediaSource: mediaSource, width: width, height: height))
|
||||
if let getMediaThumbnailMediaSourceWidthHeightClosure = getMediaThumbnailMediaSourceWidthHeightClosure {
|
||||
return try getMediaThumbnailMediaSourceWidthHeightClosure(`mediaSource`, `width`, `height`)
|
||||
} else {
|
||||
@@ -257,8 +257,8 @@ class SDKClientMock: SDKClientProtocol {
|
||||
throw error
|
||||
}
|
||||
getNotificationItemRoomIdEventIdCallsCount += 1
|
||||
getNotificationItemRoomIdEventIdReceivedArguments = (`roomId`: `roomId`, `eventId`: `eventId`)
|
||||
getNotificationItemRoomIdEventIdReceivedInvocations.append((`roomId`: `roomId`, `eventId`: `eventId`))
|
||||
getNotificationItemRoomIdEventIdReceivedArguments = (roomId: roomId, eventId: eventId)
|
||||
getNotificationItemRoomIdEventIdReceivedInvocations.append((roomId: roomId, eventId: eventId))
|
||||
if let getNotificationItemRoomIdEventIdClosure = getNotificationItemRoomIdEventIdClosure {
|
||||
return try getNotificationItemRoomIdEventIdClosure(`roomId`, `eventId`)
|
||||
} else {
|
||||
@@ -364,8 +364,8 @@ class SDKClientMock: SDKClientProtocol {
|
||||
throw error
|
||||
}
|
||||
loginUsernamePasswordInitialDeviceNameDeviceIdCallsCount += 1
|
||||
loginUsernamePasswordInitialDeviceNameDeviceIdReceivedArguments = (`username`: `username`, `password`: `password`, `initialDeviceName`: `initialDeviceName`, `deviceId`: `deviceId`)
|
||||
loginUsernamePasswordInitialDeviceNameDeviceIdReceivedInvocations.append((`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))
|
||||
try loginUsernamePasswordInitialDeviceNameDeviceIdClosure?(`username`, `password`, `initialDeviceName`, `deviceId`)
|
||||
}
|
||||
//MARK: - `logout`
|
||||
@@ -438,8 +438,8 @@ class SDKClientMock: SDKClientProtocol {
|
||||
throw error
|
||||
}
|
||||
searchUsersSearchTermLimitCallsCount += 1
|
||||
searchUsersSearchTermLimitReceivedArguments = (`searchTerm`: `searchTerm`, `limit`: `limit`)
|
||||
searchUsersSearchTermLimitReceivedInvocations.append((`searchTerm`: `searchTerm`, `limit`: `limit`))
|
||||
searchUsersSearchTermLimitReceivedArguments = (searchTerm: searchTerm, limit: limit)
|
||||
searchUsersSearchTermLimitReceivedInvocations.append((searchTerm: searchTerm, limit: limit))
|
||||
if let searchUsersSearchTermLimitClosure = searchUsersSearchTermLimitClosure {
|
||||
return try searchUsersSearchTermLimitClosure(`searchTerm`, `limit`)
|
||||
} else {
|
||||
@@ -483,8 +483,8 @@ class SDKClientMock: SDKClientProtocol {
|
||||
throw error
|
||||
}
|
||||
setAccountDataEventTypeContentCallsCount += 1
|
||||
setAccountDataEventTypeContentReceivedArguments = (`eventType`: `eventType`, `content`: `content`)
|
||||
setAccountDataEventTypeContentReceivedInvocations.append((`eventType`: `eventType`, `content`: `content`))
|
||||
setAccountDataEventTypeContentReceivedArguments = (eventType: eventType, content: content)
|
||||
setAccountDataEventTypeContentReceivedInvocations.append((eventType: eventType, content: content))
|
||||
try setAccountDataEventTypeContentClosure?(`eventType`, `content`)
|
||||
}
|
||||
//MARK: - `setDelegate`
|
||||
@@ -555,10 +555,35 @@ class SDKClientMock: SDKClientProtocol {
|
||||
throw error
|
||||
}
|
||||
setPusherIdentifiersKindAppDisplayNameDeviceDisplayNameProfileTagLangCallsCount += 1
|
||||
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`))
|
||||
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))
|
||||
try setPusherIdentifiersKindAppDisplayNameDeviceDisplayNameProfileTagLangClosure?(`identifiers`, `kind`, `appDisplayName`, `deviceDisplayName`, `profileTag`, `lang`)
|
||||
}
|
||||
//MARK: - `slidingSync`
|
||||
|
||||
public var slidingSyncIdThrowableError: Error?
|
||||
public var slidingSyncIdCallsCount = 0
|
||||
public var slidingSyncIdCalled: Bool {
|
||||
return slidingSyncIdCallsCount > 0
|
||||
}
|
||||
public var slidingSyncIdReceivedId: String?
|
||||
public var slidingSyncIdReceivedInvocations: [String] = []
|
||||
public var slidingSyncIdReturnValue: SlidingSyncBuilder!
|
||||
public var slidingSyncIdClosure: ((String) throws -> SlidingSyncBuilder)?
|
||||
|
||||
public func `slidingSync`(`id`: String) throws -> SlidingSyncBuilder {
|
||||
if let error = slidingSyncIdThrowableError {
|
||||
throw error
|
||||
}
|
||||
slidingSyncIdCallsCount += 1
|
||||
slidingSyncIdReceivedId = id
|
||||
slidingSyncIdReceivedInvocations.append(`id`)
|
||||
if let slidingSyncIdClosure = slidingSyncIdClosure {
|
||||
return try slidingSyncIdClosure(`id`)
|
||||
} else {
|
||||
return slidingSyncIdReturnValue
|
||||
}
|
||||
}
|
||||
//MARK: - `unignoreUser`
|
||||
|
||||
public var unignoreUserUserIdThrowableError: Error?
|
||||
@@ -596,8 +621,8 @@ class SDKClientMock: SDKClientProtocol {
|
||||
throw error
|
||||
}
|
||||
uploadMediaMimeTypeDataCallsCount += 1
|
||||
uploadMediaMimeTypeDataReceivedArguments = (`mimeType`: `mimeType`, `data`: `data`)
|
||||
uploadMediaMimeTypeDataReceivedInvocations.append((`mimeType`: `mimeType`, `data`: `data`))
|
||||
uploadMediaMimeTypeDataReceivedArguments = (mimeType: mimeType, data: data)
|
||||
uploadMediaMimeTypeDataReceivedInvocations.append((mimeType: mimeType, data: data))
|
||||
if let uploadMediaMimeTypeDataClosure = uploadMediaMimeTypeDataClosure {
|
||||
return try uploadMediaMimeTypeDataClosure(`mimeType`, `data`)
|
||||
} else {
|
||||
@@ -625,30 +650,5 @@ class SDKClientMock: SDKClientProtocol {
|
||||
return userIdReturnValue
|
||||
}
|
||||
}
|
||||
//MARK: - `slidingSync`
|
||||
|
||||
public var slidingSyncIdThrowableError: Error?
|
||||
public var slidingSyncIdCallsCount = 0
|
||||
public var slidingSyncIdCalled: Bool {
|
||||
return slidingSyncIdCallsCount > 0
|
||||
}
|
||||
public var slidingSyncIdReceivedId: String?
|
||||
public var slidingSyncIdReceivedInvocations: [String] = []
|
||||
public var slidingSyncIdReturnValue: SlidingSyncBuilder!
|
||||
public var slidingSyncIdClosure: ((String) throws -> SlidingSyncBuilder)?
|
||||
|
||||
public func `slidingSync`(`id`: String) throws -> SlidingSyncBuilder {
|
||||
if let error = slidingSyncIdThrowableError {
|
||||
throw error
|
||||
}
|
||||
slidingSyncIdCallsCount += 1
|
||||
slidingSyncIdReceivedId = id
|
||||
slidingSyncIdReceivedInvocations.append(`id`)
|
||||
if let slidingSyncIdClosure = slidingSyncIdClosure {
|
||||
return try slidingSyncIdClosure(`id`)
|
||||
} else {
|
||||
return slidingSyncIdReturnValue
|
||||
}
|
||||
}
|
||||
}
|
||||
// swiftlint:enable all
|
||||
|
||||
@@ -31,7 +31,7 @@ class RoomScreenViewModel: RoomScreenViewModelType, RoomScreenViewModelProtocol
|
||||
private let timelineController: RoomTimelineControllerProtocol
|
||||
private unowned let userIndicatorController: UserIndicatorControllerProtocol
|
||||
private var loadingTask: Task<Void, Never>?
|
||||
|
||||
|
||||
init(timelineController: RoomTimelineControllerProtocol,
|
||||
mediaProvider: MediaProviderProtocol,
|
||||
roomProxy: RoomProxyProtocol,
|
||||
@@ -47,26 +47,8 @@ class RoomScreenViewModel: RoomScreenViewModelType, RoomScreenViewModelProtocol
|
||||
readReceiptsEnabled: ServiceLocator.shared.settings.readReceiptsEnabled,
|
||||
bindings: .init(composerText: "", composerFocused: false)),
|
||||
imageProvider: mediaProvider)
|
||||
|
||||
timelineController.callbacks
|
||||
.receive(on: DispatchQueue.main)
|
||||
.sink { [weak self] callback in
|
||||
guard let self else { return }
|
||||
|
||||
switch callback {
|
||||
case .updatedTimelineItems:
|
||||
self.buildTimelineViews()
|
||||
case .canBackPaginate(let canBackPaginate):
|
||||
if self.state.canBackPaginate != canBackPaginate {
|
||||
self.state.canBackPaginate = canBackPaginate
|
||||
}
|
||||
case .isBackPaginating(let isBackPaginating):
|
||||
if self.state.isBackPaginating != isBackPaginating {
|
||||
self.state.isBackPaginating = isBackPaginating
|
||||
}
|
||||
}
|
||||
}
|
||||
.store(in: &cancellables)
|
||||
|
||||
setupSubscriptions()
|
||||
|
||||
state.timelineItemMenuActionProvider = { [weak self] itemId -> TimelineItemMenuActions? in
|
||||
guard let self else {
|
||||
@@ -75,34 +57,7 @@ class RoomScreenViewModel: RoomScreenViewModelType, RoomScreenViewModelProtocol
|
||||
|
||||
return self.timelineItemMenuActionsForItemId(itemId)
|
||||
}
|
||||
|
||||
roomProxy
|
||||
.updatesPublisher
|
||||
.throttle(for: .seconds(1), scheduler: DispatchQueue.main, latest: true)
|
||||
.sink { [weak self] _ in
|
||||
guard let self else { return }
|
||||
self.state.roomTitle = roomProxy.roomTitle
|
||||
self.state.roomAvatarURL = roomProxy.avatarURL
|
||||
}
|
||||
.store(in: &cancellables)
|
||||
|
||||
ServiceLocator.shared.settings.$timelineStyle
|
||||
.weakAssign(to: \.state.timelineStyle, on: self)
|
||||
.store(in: &cancellables)
|
||||
|
||||
ServiceLocator.shared.settings.$readReceiptsEnabled
|
||||
.weakAssign(to: \.state.readReceiptsEnabled, on: self)
|
||||
.store(in: &cancellables)
|
||||
|
||||
roomProxy.membersPublisher
|
||||
.map { members in
|
||||
members.reduce(into: [String: RoomMemberState]()) { dictionary, member in
|
||||
dictionary[member.userID] = RoomMemberState(displayName: member.displayName, avatarURL: member.avatarURL)
|
||||
}
|
||||
}
|
||||
.weakAssign(to: \.state.members, on: self)
|
||||
.store(in: &cancellables)
|
||||
|
||||
buildTimelineViews()
|
||||
}
|
||||
|
||||
@@ -158,6 +113,55 @@ class RoomScreenViewModel: RoomScreenViewModelType, RoomScreenViewModelProtocol
|
||||
}
|
||||
|
||||
// MARK: - Private
|
||||
|
||||
private func setupSubscriptions() {
|
||||
timelineController.callbacks
|
||||
.receive(on: DispatchQueue.main)
|
||||
.sink { [weak self] callback in
|
||||
guard let self else { return }
|
||||
|
||||
switch callback {
|
||||
case .updatedTimelineItems:
|
||||
self.buildTimelineViews()
|
||||
case .canBackPaginate(let canBackPaginate):
|
||||
if self.state.canBackPaginate != canBackPaginate {
|
||||
self.state.canBackPaginate = canBackPaginate
|
||||
}
|
||||
case .isBackPaginating(let isBackPaginating):
|
||||
if self.state.isBackPaginating != isBackPaginating {
|
||||
self.state.isBackPaginating = isBackPaginating
|
||||
}
|
||||
}
|
||||
}
|
||||
.store(in: &cancellables)
|
||||
|
||||
roomProxy
|
||||
.updatesPublisher
|
||||
.throttle(for: .seconds(1), scheduler: DispatchQueue.main, latest: true)
|
||||
.sink { [weak self] _ in
|
||||
guard let self else { return }
|
||||
self.state.roomTitle = roomProxy.roomTitle
|
||||
self.state.roomAvatarURL = roomProxy.avatarURL
|
||||
}
|
||||
.store(in: &cancellables)
|
||||
|
||||
ServiceLocator.shared.settings.$timelineStyle
|
||||
.weakAssign(to: \.state.timelineStyle, on: self)
|
||||
.store(in: &cancellables)
|
||||
|
||||
ServiceLocator.shared.settings.$readReceiptsEnabled
|
||||
.weakAssign(to: \.state.readReceiptsEnabled, on: self)
|
||||
.store(in: &cancellables)
|
||||
|
||||
roomProxy.membersPublisher
|
||||
.map { members in
|
||||
members.reduce(into: [String: RoomMemberState]()) { dictionary, member in
|
||||
dictionary[member.userID] = RoomMemberState(displayName: member.displayName, avatarURL: member.avatarURL)
|
||||
}
|
||||
}
|
||||
.weakAssign(to: \.state.members, on: self)
|
||||
.store(in: &cancellables)
|
||||
}
|
||||
|
||||
private func paginateBackwards() async {
|
||||
switch await timelineController.paginateBackwards(requestSize: Constants.backPaginationEventLimit, untilNumberOfItems: Constants.backPaginationPageSize) {
|
||||
|
||||
@@ -198,7 +198,7 @@ class RoomProxy: RoomProxyProtocol {
|
||||
func paginateBackwards(requestSize: UInt, untilNumberOfItems: UInt) async -> Result<Void, RoomProxyError> {
|
||||
do {
|
||||
try await Task.dispatch(on: .global()) {
|
||||
try self.room.paginateBackwards(opts: .untilNumItems(eventLimit: UInt16(requestSize), items: UInt16(untilNumberOfItems)))
|
||||
try self.room.paginateBackwards(opts: .untilNumItems(eventLimit: UInt16(requestSize), items: UInt16(untilNumberOfItems), waitForToken: true))
|
||||
}
|
||||
|
||||
return .success(())
|
||||
|
||||
Reference in New Issue
Block a user