Update SDK to 1.0.106-alpha (#1480)

This commit is contained in:
Nicolas Mauri
2023-08-11 11:54:44 +02:00
committed by GitHub
parent 27c3cdce62
commit f64159670b
15 changed files with 99 additions and 101 deletions
@@ -322,27 +322,27 @@ class NotificationSettingsProxyMock: NotificationSettingsProxyProtocol {
//MARK: - getNotificationSettings
var getNotificationSettingsRoomIdIsEncryptedActiveMembersCountThrowableError: Error?
var getNotificationSettingsRoomIdIsEncryptedActiveMembersCountCallsCount = 0
var getNotificationSettingsRoomIdIsEncryptedActiveMembersCountCalled: Bool {
return getNotificationSettingsRoomIdIsEncryptedActiveMembersCountCallsCount > 0
var getNotificationSettingsRoomIdIsEncryptedIsOneToOneThrowableError: Error?
var getNotificationSettingsRoomIdIsEncryptedIsOneToOneCallsCount = 0
var getNotificationSettingsRoomIdIsEncryptedIsOneToOneCalled: Bool {
return getNotificationSettingsRoomIdIsEncryptedIsOneToOneCallsCount > 0
}
var getNotificationSettingsRoomIdIsEncryptedActiveMembersCountReceivedArguments: (roomId: String, isEncrypted: Bool, activeMembersCount: UInt64)?
var getNotificationSettingsRoomIdIsEncryptedActiveMembersCountReceivedInvocations: [(roomId: String, isEncrypted: Bool, activeMembersCount: UInt64)] = []
var getNotificationSettingsRoomIdIsEncryptedActiveMembersCountReturnValue: RoomNotificationSettingsProxyProtocol!
var getNotificationSettingsRoomIdIsEncryptedActiveMembersCountClosure: ((String, Bool, UInt64) async throws -> RoomNotificationSettingsProxyProtocol)?
var getNotificationSettingsRoomIdIsEncryptedIsOneToOneReceivedArguments: (roomId: String, isEncrypted: Bool, isOneToOne: Bool)?
var getNotificationSettingsRoomIdIsEncryptedIsOneToOneReceivedInvocations: [(roomId: String, isEncrypted: Bool, isOneToOne: Bool)] = []
var getNotificationSettingsRoomIdIsEncryptedIsOneToOneReturnValue: RoomNotificationSettingsProxyProtocol!
var getNotificationSettingsRoomIdIsEncryptedIsOneToOneClosure: ((String, Bool, Bool) async throws -> RoomNotificationSettingsProxyProtocol)?
func getNotificationSettings(roomId: String, isEncrypted: Bool, activeMembersCount: UInt64) async throws -> RoomNotificationSettingsProxyProtocol {
if let error = getNotificationSettingsRoomIdIsEncryptedActiveMembersCountThrowableError {
func getNotificationSettings(roomId: String, isEncrypted: Bool, isOneToOne: Bool) async throws -> RoomNotificationSettingsProxyProtocol {
if let error = getNotificationSettingsRoomIdIsEncryptedIsOneToOneThrowableError {
throw error
}
getNotificationSettingsRoomIdIsEncryptedActiveMembersCountCallsCount += 1
getNotificationSettingsRoomIdIsEncryptedActiveMembersCountReceivedArguments = (roomId: roomId, isEncrypted: isEncrypted, activeMembersCount: activeMembersCount)
getNotificationSettingsRoomIdIsEncryptedActiveMembersCountReceivedInvocations.append((roomId: roomId, isEncrypted: isEncrypted, activeMembersCount: activeMembersCount))
if let getNotificationSettingsRoomIdIsEncryptedActiveMembersCountClosure = getNotificationSettingsRoomIdIsEncryptedActiveMembersCountClosure {
return try await getNotificationSettingsRoomIdIsEncryptedActiveMembersCountClosure(roomId, isEncrypted, activeMembersCount)
getNotificationSettingsRoomIdIsEncryptedIsOneToOneCallsCount += 1
getNotificationSettingsRoomIdIsEncryptedIsOneToOneReceivedArguments = (roomId: roomId, isEncrypted: isEncrypted, isOneToOne: isOneToOne)
getNotificationSettingsRoomIdIsEncryptedIsOneToOneReceivedInvocations.append((roomId: roomId, isEncrypted: isEncrypted, isOneToOne: isOneToOne))
if let getNotificationSettingsRoomIdIsEncryptedIsOneToOneClosure = getNotificationSettingsRoomIdIsEncryptedIsOneToOneClosure {
return try await getNotificationSettingsRoomIdIsEncryptedIsOneToOneClosure(roomId, isEncrypted, isOneToOne)
} else {
return getNotificationSettingsRoomIdIsEncryptedActiveMembersCountReturnValue
return getNotificationSettingsRoomIdIsEncryptedIsOneToOneReturnValue
}
}
//MARK: - setNotificationMode
@@ -367,23 +367,23 @@ class NotificationSettingsProxyMock: NotificationSettingsProxyProtocol {
}
//MARK: - getDefaultNotificationRoomMode
var getDefaultNotificationRoomModeIsEncryptedActiveMembersCountCallsCount = 0
var getDefaultNotificationRoomModeIsEncryptedActiveMembersCountCalled: Bool {
return getDefaultNotificationRoomModeIsEncryptedActiveMembersCountCallsCount > 0
var getDefaultNotificationRoomModeIsEncryptedIsOneToOneCallsCount = 0
var getDefaultNotificationRoomModeIsEncryptedIsOneToOneCalled: Bool {
return getDefaultNotificationRoomModeIsEncryptedIsOneToOneCallsCount > 0
}
var getDefaultNotificationRoomModeIsEncryptedActiveMembersCountReceivedArguments: (isEncrypted: Bool, activeMembersCount: UInt64)?
var getDefaultNotificationRoomModeIsEncryptedActiveMembersCountReceivedInvocations: [(isEncrypted: Bool, activeMembersCount: UInt64)] = []
var getDefaultNotificationRoomModeIsEncryptedActiveMembersCountReturnValue: RoomNotificationModeProxy!
var getDefaultNotificationRoomModeIsEncryptedActiveMembersCountClosure: ((Bool, UInt64) async -> RoomNotificationModeProxy)?
var getDefaultNotificationRoomModeIsEncryptedIsOneToOneReceivedArguments: (isEncrypted: Bool, isOneToOne: Bool)?
var getDefaultNotificationRoomModeIsEncryptedIsOneToOneReceivedInvocations: [(isEncrypted: Bool, isOneToOne: Bool)] = []
var getDefaultNotificationRoomModeIsEncryptedIsOneToOneReturnValue: RoomNotificationModeProxy!
var getDefaultNotificationRoomModeIsEncryptedIsOneToOneClosure: ((Bool, Bool) async -> RoomNotificationModeProxy)?
func getDefaultNotificationRoomMode(isEncrypted: Bool, activeMembersCount: UInt64) async -> RoomNotificationModeProxy {
getDefaultNotificationRoomModeIsEncryptedActiveMembersCountCallsCount += 1
getDefaultNotificationRoomModeIsEncryptedActiveMembersCountReceivedArguments = (isEncrypted: isEncrypted, activeMembersCount: activeMembersCount)
getDefaultNotificationRoomModeIsEncryptedActiveMembersCountReceivedInvocations.append((isEncrypted: isEncrypted, activeMembersCount: activeMembersCount))
if let getDefaultNotificationRoomModeIsEncryptedActiveMembersCountClosure = getDefaultNotificationRoomModeIsEncryptedActiveMembersCountClosure {
return await getDefaultNotificationRoomModeIsEncryptedActiveMembersCountClosure(isEncrypted, activeMembersCount)
func getDefaultNotificationRoomMode(isEncrypted: Bool, isOneToOne: Bool) async -> RoomNotificationModeProxy {
getDefaultNotificationRoomModeIsEncryptedIsOneToOneCallsCount += 1
getDefaultNotificationRoomModeIsEncryptedIsOneToOneReceivedArguments = (isEncrypted: isEncrypted, isOneToOne: isOneToOne)
getDefaultNotificationRoomModeIsEncryptedIsOneToOneReceivedInvocations.append((isEncrypted: isEncrypted, isOneToOne: isOneToOne))
if let getDefaultNotificationRoomModeIsEncryptedIsOneToOneClosure = getDefaultNotificationRoomModeIsEncryptedIsOneToOneClosure {
return await getDefaultNotificationRoomModeIsEncryptedIsOneToOneClosure(isEncrypted, isOneToOne)
} else {
return getDefaultNotificationRoomModeIsEncryptedActiveMembersCountReturnValue
return getDefaultNotificationRoomModeIsEncryptedIsOneToOneReturnValue
}
}
//MARK: - restoreDefaultNotificationMode
@@ -425,23 +425,23 @@ class NotificationSettingsProxyMock: NotificationSettingsProxyProtocol {
}
//MARK: - unmuteRoom
var unmuteRoomRoomIdIsEncryptedActiveMembersCountThrowableError: Error?
var unmuteRoomRoomIdIsEncryptedActiveMembersCountCallsCount = 0
var unmuteRoomRoomIdIsEncryptedActiveMembersCountCalled: Bool {
return unmuteRoomRoomIdIsEncryptedActiveMembersCountCallsCount > 0
var unmuteRoomRoomIdIsEncryptedIsOneToOneThrowableError: Error?
var unmuteRoomRoomIdIsEncryptedIsOneToOneCallsCount = 0
var unmuteRoomRoomIdIsEncryptedIsOneToOneCalled: Bool {
return unmuteRoomRoomIdIsEncryptedIsOneToOneCallsCount > 0
}
var unmuteRoomRoomIdIsEncryptedActiveMembersCountReceivedArguments: (roomId: String, isEncrypted: Bool, activeMembersCount: UInt64)?
var unmuteRoomRoomIdIsEncryptedActiveMembersCountReceivedInvocations: [(roomId: String, isEncrypted: Bool, activeMembersCount: UInt64)] = []
var unmuteRoomRoomIdIsEncryptedActiveMembersCountClosure: ((String, Bool, UInt64) async throws -> Void)?
var unmuteRoomRoomIdIsEncryptedIsOneToOneReceivedArguments: (roomId: String, isEncrypted: Bool, isOneToOne: Bool)?
var unmuteRoomRoomIdIsEncryptedIsOneToOneReceivedInvocations: [(roomId: String, isEncrypted: Bool, isOneToOne: Bool)] = []
var unmuteRoomRoomIdIsEncryptedIsOneToOneClosure: ((String, Bool, Bool) async throws -> Void)?
func unmuteRoom(roomId: String, isEncrypted: Bool, activeMembersCount: UInt64) async throws {
if let error = unmuteRoomRoomIdIsEncryptedActiveMembersCountThrowableError {
func unmuteRoom(roomId: String, isEncrypted: Bool, isOneToOne: Bool) async throws {
if let error = unmuteRoomRoomIdIsEncryptedIsOneToOneThrowableError {
throw error
}
unmuteRoomRoomIdIsEncryptedActiveMembersCountCallsCount += 1
unmuteRoomRoomIdIsEncryptedActiveMembersCountReceivedArguments = (roomId: roomId, isEncrypted: isEncrypted, activeMembersCount: activeMembersCount)
unmuteRoomRoomIdIsEncryptedActiveMembersCountReceivedInvocations.append((roomId: roomId, isEncrypted: isEncrypted, activeMembersCount: activeMembersCount))
try await unmuteRoomRoomIdIsEncryptedActiveMembersCountClosure?(roomId, isEncrypted, activeMembersCount)
unmuteRoomRoomIdIsEncryptedIsOneToOneCallsCount += 1
unmuteRoomRoomIdIsEncryptedIsOneToOneReceivedArguments = (roomId: roomId, isEncrypted: isEncrypted, isOneToOne: isOneToOne)
unmuteRoomRoomIdIsEncryptedIsOneToOneReceivedInvocations.append((roomId: roomId, isEncrypted: isEncrypted, isOneToOne: isOneToOne))
try await unmuteRoomRoomIdIsEncryptedIsOneToOneClosure?(roomId, isEncrypted, isOneToOne)
}
//MARK: - isRoomMentionEnabled
@@ -34,19 +34,19 @@ extension NotificationSettingsProxyMock {
self.init()
callbacks = configuration.callback
getNotificationSettingsRoomIdIsEncryptedActiveMembersCountReturnValue = configuration.roomMode
getDefaultNotificationRoomModeIsEncryptedActiveMembersCountReturnValue = configuration.defaultRoomMode
getNotificationSettingsRoomIdIsEncryptedIsOneToOneReturnValue = configuration.roomMode
getDefaultNotificationRoomModeIsEncryptedIsOneToOneReturnValue = configuration.defaultRoomMode
setNotificationModeRoomIdModeClosure = { [weak self] _, mode in
guard let self else { return }
self.getNotificationSettingsRoomIdIsEncryptedActiveMembersCountReturnValue = RoomNotificationSettingsProxyMock(with: .init(mode: mode, isDefault: false))
self.getNotificationSettingsRoomIdIsEncryptedIsOneToOneReturnValue = RoomNotificationSettingsProxyMock(with: .init(mode: mode, isDefault: false))
Task {
self.callbacks.send(.settingsDidChange)
}
}
restoreDefaultNotificationModeRoomIdClosure = { [weak self] _ in
guard let self else { return }
self.getNotificationSettingsRoomIdIsEncryptedActiveMembersCountReturnValue = RoomNotificationSettingsProxyMock(with: .init(mode: configuration.defaultRoomMode, isDefault: true))
self.getNotificationSettingsRoomIdIsEncryptedIsOneToOneReturnValue = RoomNotificationSettingsProxyMock(with: .init(mode: configuration.defaultRoomMode, isDefault: true))
Task {
self.callbacks.send(.settingsDidChange)
}
@@ -195,7 +195,7 @@ class RoomDetailsScreenViewModel: RoomDetailsScreenViewModelType, RoomDetailsScr
do {
let notificationMode = try await notificationSettingsProxy.getNotificationSettings(roomId: roomProxy.id,
isEncrypted: roomProxy.isEncrypted,
activeMembersCount: UInt64(roomProxy.activeMembersCount))
isOneToOne: roomProxy.activeMembersCount == 2)
state.notificationSettingsState = .loaded(settings: notificationMode)
} catch {
state.notificationSettingsState = .error
@@ -213,7 +213,7 @@ class RoomDetailsScreenViewModel: RoomDetailsScreenViewModelType, RoomDetailsScr
do {
try await notificationSettingsProxy.unmuteRoom(roomId: roomProxy.id,
isEncrypted: roomProxy.isEncrypted,
activeMembersCount: UInt64(roomProxy.activeMembersCount))
isOneToOne: roomProxy.activeMembersCount == 2)
} catch {
state.bindings.alertInfo = AlertInfo(id: .alert,
title: L10n.commonError,
@@ -79,7 +79,7 @@ class RoomNotificationSettingsScreenViewModel: RoomNotificationSettingsScreenVie
do {
let settings = try await notificationSettingsProxy.getNotificationSettings(roomId: roomProxy.id,
isEncrypted: roomProxy.isEncrypted,
activeMembersCount: UInt64(roomProxy.activeMembersCount))
isOneToOne: roomProxy.activeMembersCount == 2)
guard !Task.isCancelled else { return }
state.notificationSettingsState = .loaded(settings: settings)
if !state.isRestoringDefautSetting {
@@ -121,15 +121,13 @@ class NotificationSettingsScreenViewModel: NotificationSettingsScreenViewModelTy
fetchSettingsTask = Task {
// Group chats
// A group chat is a chat having more than 2 active members
let groupChatActiveMembers: UInt64 = 3
var groupChatsMode = await notificationSettingsProxy.getDefaultNotificationRoomMode(isEncrypted: false, activeMembersCount: groupChatActiveMembers)
let encryptedGroupChatsMode = await notificationSettingsProxy.getDefaultNotificationRoomMode(isEncrypted: true, activeMembersCount: groupChatActiveMembers)
var groupChatsMode = await notificationSettingsProxy.getDefaultNotificationRoomMode(isEncrypted: false, isOneToOne: false)
let encryptedGroupChatsMode = await notificationSettingsProxy.getDefaultNotificationRoomMode(isEncrypted: true, isOneToOne: false)
// Direct chats
// A direct chat is a chat having exactly 2 active members
let directChatActiveMembers: UInt64 = 2
var directChatsMode = await notificationSettingsProxy.getDefaultNotificationRoomMode(isEncrypted: false, activeMembersCount: directChatActiveMembers)
let encryptedDirectChatsMode = await notificationSettingsProxy.getDefaultNotificationRoomMode(isEncrypted: true, activeMembersCount: directChatActiveMembers)
var directChatsMode = await notificationSettingsProxy.getDefaultNotificationRoomMode(isEncrypted: false, isOneToOne: true)
let encryptedDirectChatsMode = await notificationSettingsProxy.getDefaultNotificationRoomMode(isEncrypted: true, isOneToOne: true)
// Old clients were having specific settings for encrypted and unencrypted rooms,
// so it's possible for `group chats` and `direct chats` settings to be inconsistent (e.g. encrypted `direct chats` can have a different mode that unencrypted `direct chats`)
@@ -183,9 +183,9 @@ struct NotificationSettingsScreen_Previews: PreviewProvider {
let notificationCenter = UserNotificationCenterMock()
notificationCenter.authorizationStatusReturnValue = .notDetermined
let notificationSettingsProxy = NotificationSettingsProxyMock(with: .init())
notificationSettingsProxy.getDefaultNotificationRoomModeIsEncryptedActiveMembersCountClosure = { isEncrypted, activeMembersCount in
switch (isEncrypted, activeMembersCount) {
case (_, 2):
notificationSettingsProxy.getDefaultNotificationRoomModeIsEncryptedIsOneToOneClosure = { isEncrypted, isOneToOne in
switch (isEncrypted, isOneToOne) {
case (_, true):
return .allMessages
default:
return .mentionsAndKeywordsOnly
@@ -46,8 +46,8 @@ final class NotificationSettingsProxy: NotificationSettingsProxyProtocol {
notificationSettings.setDelegate(delegate: WeakNotificationSettingsProxy(proxy: self))
}
func getNotificationSettings(roomId: String, isEncrypted: Bool, activeMembersCount: UInt64) async throws -> RoomNotificationSettingsProxyProtocol {
let roomMotificationSettings = try await notificationSettings.getRoomNotificationSettings(roomId: roomId, isEncrypted: isEncrypted, activeMembersCount: activeMembersCount)
func getNotificationSettings(roomId: String, isEncrypted: Bool, isOneToOne: Bool) async throws -> RoomNotificationSettingsProxyProtocol {
let roomMotificationSettings = try await notificationSettings.getRoomNotificationSettings(roomId: roomId, isEncrypted: isEncrypted, isOneToOne: isOneToOne)
return RoomNotificationSettingsProxy(roomNotificationSettings: roomMotificationSettings)
}
@@ -68,8 +68,8 @@ final class NotificationSettingsProxy: NotificationSettingsProxyProtocol {
await updatedSettings()
}
func getDefaultNotificationRoomMode(isEncrypted: Bool, activeMembersCount: UInt64) async -> RoomNotificationModeProxy {
let roomNotificationMode = await notificationSettings.getDefaultRoomNotificationMode(isEncrypted: isEncrypted, activeMembersCount: activeMembersCount)
func getDefaultNotificationRoomMode(isEncrypted: Bool, isOneToOne: Bool) async -> RoomNotificationModeProxy {
let roomNotificationMode = await notificationSettings.getDefaultRoomNotificationMode(isEncrypted: isEncrypted, isOneToOne: isOneToOne)
return RoomNotificationModeProxy.from(roomNotificationMode: roomNotificationMode)
}
@@ -85,11 +85,11 @@ final class NotificationSettingsProxy: NotificationSettingsProxyProtocol {
await notificationSettings.containsKeywordsRules()
}
func unmuteRoom(roomId: String, isEncrypted: Bool, activeMembersCount: UInt64) async throws {
func unmuteRoom(roomId: String, isEncrypted: Bool, isOneToOne: Bool) async throws {
let backgroundTask = await backgroundTaskService?.startBackgroundTask(withName: "unmuteRoom")
defer { backgroundTask?.stop() }
try await notificationSettings.unmuteRoom(roomId: roomId, isEncrypted: isEncrypted, membersCount: activeMembersCount)
try await notificationSettings.unmuteRoom(roomId: roomId, isEncrypted: isEncrypted, isOneToOne: isOneToOne)
await updatedSettings()
}
@@ -26,12 +26,12 @@ enum NotificationSettingsProxyCallback {
protocol NotificationSettingsProxyProtocol {
var callbacks: PassthroughSubject<NotificationSettingsProxyCallback, Never> { get }
func getNotificationSettings(roomId: String, isEncrypted: Bool, activeMembersCount: UInt64) async throws -> RoomNotificationSettingsProxyProtocol
func getNotificationSettings(roomId: String, isEncrypted: Bool, isOneToOne: Bool) async throws -> RoomNotificationSettingsProxyProtocol
func setNotificationMode(roomId: String, mode: RoomNotificationModeProxy) async throws
func getDefaultNotificationRoomMode(isEncrypted: Bool, activeMembersCount: UInt64) async -> RoomNotificationModeProxy
func getDefaultNotificationRoomMode(isEncrypted: Bool, isOneToOne: Bool) async -> RoomNotificationModeProxy
func restoreDefaultNotificationMode(roomId: String) async throws
func containsKeywordsRules() async -> Bool
func unmuteRoom(roomId: String, isEncrypted: Bool, activeMembersCount: UInt64) async throws
func unmuteRoom(roomId: String, isEncrypted: Bool, isOneToOne: Bool) async throws
func isRoomMentionEnabled() async throws -> Bool
func setRoomMentionEnabled(enabled: Bool) async throws
func isUserMentionEnabled() async throws -> Bool
@@ -73,7 +73,7 @@ class RoomSummaryProvider: RoomSummaryProviderProtocol {
self.roomList = roomList
do {
let listUpdatesSubscriptionResult = try roomList.entries(listener: RoomListEntriesListenerProxy { [weak self] updates in
let listUpdatesSubscriptionResult = roomList.entries(listener: RoomListEntriesListenerProxy { [weak self] updates in
guard let self else { return }
MXLog.info("\(name): Received list update")
diffsPublisher.send(updates)