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
+1 -1
View File
@@ -5402,7 +5402,7 @@
repositoryURL = "https://github.com/matrix-org/matrix-rust-components-swift"; repositoryURL = "https://github.com/matrix-org/matrix-rust-components-swift";
requirement = { requirement = {
kind = exactVersion; kind = exactVersion;
version = "1.0.105-alpha"; version = "1.0.106-alpha";
}; };
}; };
821C67C9A7F8CC3FD41B28B4 /* XCRemoteSwiftPackageReference "emojibase-bindings" */ = { 821C67C9A7F8CC3FD41B28B4 /* XCRemoteSwiftPackageReference "emojibase-bindings" */ = {
@@ -129,8 +129,8 @@
"kind" : "remoteSourceControl", "kind" : "remoteSourceControl",
"location" : "https://github.com/matrix-org/matrix-rust-components-swift", "location" : "https://github.com/matrix-org/matrix-rust-components-swift",
"state" : { "state" : {
"revision" : "ce67b9e191755f8562f1f1eccc195ebbb696cfb2", "revision" : "e9c185dc6a9d01c198fae36161b0e4180dfcfdd6",
"version" : "1.0.105-alpha" "version" : "1.0.106-alpha"
} }
}, },
{ {
@@ -322,27 +322,27 @@ class NotificationSettingsProxyMock: NotificationSettingsProxyProtocol {
//MARK: - getNotificationSettings //MARK: - getNotificationSettings
var getNotificationSettingsRoomIdIsEncryptedActiveMembersCountThrowableError: Error? var getNotificationSettingsRoomIdIsEncryptedIsOneToOneThrowableError: Error?
var getNotificationSettingsRoomIdIsEncryptedActiveMembersCountCallsCount = 0 var getNotificationSettingsRoomIdIsEncryptedIsOneToOneCallsCount = 0
var getNotificationSettingsRoomIdIsEncryptedActiveMembersCountCalled: Bool { var getNotificationSettingsRoomIdIsEncryptedIsOneToOneCalled: Bool {
return getNotificationSettingsRoomIdIsEncryptedActiveMembersCountCallsCount > 0 return getNotificationSettingsRoomIdIsEncryptedIsOneToOneCallsCount > 0
} }
var getNotificationSettingsRoomIdIsEncryptedActiveMembersCountReceivedArguments: (roomId: String, isEncrypted: Bool, activeMembersCount: UInt64)? var getNotificationSettingsRoomIdIsEncryptedIsOneToOneReceivedArguments: (roomId: String, isEncrypted: Bool, isOneToOne: Bool)?
var getNotificationSettingsRoomIdIsEncryptedActiveMembersCountReceivedInvocations: [(roomId: String, isEncrypted: Bool, activeMembersCount: UInt64)] = [] var getNotificationSettingsRoomIdIsEncryptedIsOneToOneReceivedInvocations: [(roomId: String, isEncrypted: Bool, isOneToOne: Bool)] = []
var getNotificationSettingsRoomIdIsEncryptedActiveMembersCountReturnValue: RoomNotificationSettingsProxyProtocol! var getNotificationSettingsRoomIdIsEncryptedIsOneToOneReturnValue: RoomNotificationSettingsProxyProtocol!
var getNotificationSettingsRoomIdIsEncryptedActiveMembersCountClosure: ((String, Bool, UInt64) async throws -> RoomNotificationSettingsProxyProtocol)? var getNotificationSettingsRoomIdIsEncryptedIsOneToOneClosure: ((String, Bool, Bool) async throws -> RoomNotificationSettingsProxyProtocol)?
func getNotificationSettings(roomId: String, isEncrypted: Bool, activeMembersCount: UInt64) async throws -> RoomNotificationSettingsProxyProtocol { func getNotificationSettings(roomId: String, isEncrypted: Bool, isOneToOne: Bool) async throws -> RoomNotificationSettingsProxyProtocol {
if let error = getNotificationSettingsRoomIdIsEncryptedActiveMembersCountThrowableError { if let error = getNotificationSettingsRoomIdIsEncryptedIsOneToOneThrowableError {
throw error throw error
} }
getNotificationSettingsRoomIdIsEncryptedActiveMembersCountCallsCount += 1 getNotificationSettingsRoomIdIsEncryptedIsOneToOneCallsCount += 1
getNotificationSettingsRoomIdIsEncryptedActiveMembersCountReceivedArguments = (roomId: roomId, isEncrypted: isEncrypted, activeMembersCount: activeMembersCount) getNotificationSettingsRoomIdIsEncryptedIsOneToOneReceivedArguments = (roomId: roomId, isEncrypted: isEncrypted, isOneToOne: isOneToOne)
getNotificationSettingsRoomIdIsEncryptedActiveMembersCountReceivedInvocations.append((roomId: roomId, isEncrypted: isEncrypted, activeMembersCount: activeMembersCount)) getNotificationSettingsRoomIdIsEncryptedIsOneToOneReceivedInvocations.append((roomId: roomId, isEncrypted: isEncrypted, isOneToOne: isOneToOne))
if let getNotificationSettingsRoomIdIsEncryptedActiveMembersCountClosure = getNotificationSettingsRoomIdIsEncryptedActiveMembersCountClosure { if let getNotificationSettingsRoomIdIsEncryptedIsOneToOneClosure = getNotificationSettingsRoomIdIsEncryptedIsOneToOneClosure {
return try await getNotificationSettingsRoomIdIsEncryptedActiveMembersCountClosure(roomId, isEncrypted, activeMembersCount) return try await getNotificationSettingsRoomIdIsEncryptedIsOneToOneClosure(roomId, isEncrypted, isOneToOne)
} else { } else {
return getNotificationSettingsRoomIdIsEncryptedActiveMembersCountReturnValue return getNotificationSettingsRoomIdIsEncryptedIsOneToOneReturnValue
} }
} }
//MARK: - setNotificationMode //MARK: - setNotificationMode
@@ -367,23 +367,23 @@ class NotificationSettingsProxyMock: NotificationSettingsProxyProtocol {
} }
//MARK: - getDefaultNotificationRoomMode //MARK: - getDefaultNotificationRoomMode
var getDefaultNotificationRoomModeIsEncryptedActiveMembersCountCallsCount = 0 var getDefaultNotificationRoomModeIsEncryptedIsOneToOneCallsCount = 0
var getDefaultNotificationRoomModeIsEncryptedActiveMembersCountCalled: Bool { var getDefaultNotificationRoomModeIsEncryptedIsOneToOneCalled: Bool {
return getDefaultNotificationRoomModeIsEncryptedActiveMembersCountCallsCount > 0 return getDefaultNotificationRoomModeIsEncryptedIsOneToOneCallsCount > 0
} }
var getDefaultNotificationRoomModeIsEncryptedActiveMembersCountReceivedArguments: (isEncrypted: Bool, activeMembersCount: UInt64)? var getDefaultNotificationRoomModeIsEncryptedIsOneToOneReceivedArguments: (isEncrypted: Bool, isOneToOne: Bool)?
var getDefaultNotificationRoomModeIsEncryptedActiveMembersCountReceivedInvocations: [(isEncrypted: Bool, activeMembersCount: UInt64)] = [] var getDefaultNotificationRoomModeIsEncryptedIsOneToOneReceivedInvocations: [(isEncrypted: Bool, isOneToOne: Bool)] = []
var getDefaultNotificationRoomModeIsEncryptedActiveMembersCountReturnValue: RoomNotificationModeProxy! var getDefaultNotificationRoomModeIsEncryptedIsOneToOneReturnValue: RoomNotificationModeProxy!
var getDefaultNotificationRoomModeIsEncryptedActiveMembersCountClosure: ((Bool, UInt64) async -> RoomNotificationModeProxy)? var getDefaultNotificationRoomModeIsEncryptedIsOneToOneClosure: ((Bool, Bool) async -> RoomNotificationModeProxy)?
func getDefaultNotificationRoomMode(isEncrypted: Bool, activeMembersCount: UInt64) async -> RoomNotificationModeProxy { func getDefaultNotificationRoomMode(isEncrypted: Bool, isOneToOne: Bool) async -> RoomNotificationModeProxy {
getDefaultNotificationRoomModeIsEncryptedActiveMembersCountCallsCount += 1 getDefaultNotificationRoomModeIsEncryptedIsOneToOneCallsCount += 1
getDefaultNotificationRoomModeIsEncryptedActiveMembersCountReceivedArguments = (isEncrypted: isEncrypted, activeMembersCount: activeMembersCount) getDefaultNotificationRoomModeIsEncryptedIsOneToOneReceivedArguments = (isEncrypted: isEncrypted, isOneToOne: isOneToOne)
getDefaultNotificationRoomModeIsEncryptedActiveMembersCountReceivedInvocations.append((isEncrypted: isEncrypted, activeMembersCount: activeMembersCount)) getDefaultNotificationRoomModeIsEncryptedIsOneToOneReceivedInvocations.append((isEncrypted: isEncrypted, isOneToOne: isOneToOne))
if let getDefaultNotificationRoomModeIsEncryptedActiveMembersCountClosure = getDefaultNotificationRoomModeIsEncryptedActiveMembersCountClosure { if let getDefaultNotificationRoomModeIsEncryptedIsOneToOneClosure = getDefaultNotificationRoomModeIsEncryptedIsOneToOneClosure {
return await getDefaultNotificationRoomModeIsEncryptedActiveMembersCountClosure(isEncrypted, activeMembersCount) return await getDefaultNotificationRoomModeIsEncryptedIsOneToOneClosure(isEncrypted, isOneToOne)
} else { } else {
return getDefaultNotificationRoomModeIsEncryptedActiveMembersCountReturnValue return getDefaultNotificationRoomModeIsEncryptedIsOneToOneReturnValue
} }
} }
//MARK: - restoreDefaultNotificationMode //MARK: - restoreDefaultNotificationMode
@@ -425,23 +425,23 @@ class NotificationSettingsProxyMock: NotificationSettingsProxyProtocol {
} }
//MARK: - unmuteRoom //MARK: - unmuteRoom
var unmuteRoomRoomIdIsEncryptedActiveMembersCountThrowableError: Error? var unmuteRoomRoomIdIsEncryptedIsOneToOneThrowableError: Error?
var unmuteRoomRoomIdIsEncryptedActiveMembersCountCallsCount = 0 var unmuteRoomRoomIdIsEncryptedIsOneToOneCallsCount = 0
var unmuteRoomRoomIdIsEncryptedActiveMembersCountCalled: Bool { var unmuteRoomRoomIdIsEncryptedIsOneToOneCalled: Bool {
return unmuteRoomRoomIdIsEncryptedActiveMembersCountCallsCount > 0 return unmuteRoomRoomIdIsEncryptedIsOneToOneCallsCount > 0
} }
var unmuteRoomRoomIdIsEncryptedActiveMembersCountReceivedArguments: (roomId: String, isEncrypted: Bool, activeMembersCount: UInt64)? var unmuteRoomRoomIdIsEncryptedIsOneToOneReceivedArguments: (roomId: String, isEncrypted: Bool, isOneToOne: Bool)?
var unmuteRoomRoomIdIsEncryptedActiveMembersCountReceivedInvocations: [(roomId: String, isEncrypted: Bool, activeMembersCount: UInt64)] = [] var unmuteRoomRoomIdIsEncryptedIsOneToOneReceivedInvocations: [(roomId: String, isEncrypted: Bool, isOneToOne: Bool)] = []
var unmuteRoomRoomIdIsEncryptedActiveMembersCountClosure: ((String, Bool, UInt64) async throws -> Void)? var unmuteRoomRoomIdIsEncryptedIsOneToOneClosure: ((String, Bool, Bool) async throws -> Void)?
func unmuteRoom(roomId: String, isEncrypted: Bool, activeMembersCount: UInt64) async throws { func unmuteRoom(roomId: String, isEncrypted: Bool, isOneToOne: Bool) async throws {
if let error = unmuteRoomRoomIdIsEncryptedActiveMembersCountThrowableError { if let error = unmuteRoomRoomIdIsEncryptedIsOneToOneThrowableError {
throw error throw error
} }
unmuteRoomRoomIdIsEncryptedActiveMembersCountCallsCount += 1 unmuteRoomRoomIdIsEncryptedIsOneToOneCallsCount += 1
unmuteRoomRoomIdIsEncryptedActiveMembersCountReceivedArguments = (roomId: roomId, isEncrypted: isEncrypted, activeMembersCount: activeMembersCount) unmuteRoomRoomIdIsEncryptedIsOneToOneReceivedArguments = (roomId: roomId, isEncrypted: isEncrypted, isOneToOne: isOneToOne)
unmuteRoomRoomIdIsEncryptedActiveMembersCountReceivedInvocations.append((roomId: roomId, isEncrypted: isEncrypted, activeMembersCount: activeMembersCount)) unmuteRoomRoomIdIsEncryptedIsOneToOneReceivedInvocations.append((roomId: roomId, isEncrypted: isEncrypted, isOneToOne: isOneToOne))
try await unmuteRoomRoomIdIsEncryptedActiveMembersCountClosure?(roomId, isEncrypted, activeMembersCount) try await unmuteRoomRoomIdIsEncryptedIsOneToOneClosure?(roomId, isEncrypted, isOneToOne)
} }
//MARK: - isRoomMentionEnabled //MARK: - isRoomMentionEnabled
@@ -34,19 +34,19 @@ extension NotificationSettingsProxyMock {
self.init() self.init()
callbacks = configuration.callback callbacks = configuration.callback
getNotificationSettingsRoomIdIsEncryptedActiveMembersCountReturnValue = configuration.roomMode getNotificationSettingsRoomIdIsEncryptedIsOneToOneReturnValue = configuration.roomMode
getDefaultNotificationRoomModeIsEncryptedActiveMembersCountReturnValue = configuration.defaultRoomMode getDefaultNotificationRoomModeIsEncryptedIsOneToOneReturnValue = configuration.defaultRoomMode
setNotificationModeRoomIdModeClosure = { [weak self] _, mode in setNotificationModeRoomIdModeClosure = { [weak self] _, mode in
guard let self else { return } guard let self else { return }
self.getNotificationSettingsRoomIdIsEncryptedActiveMembersCountReturnValue = RoomNotificationSettingsProxyMock(with: .init(mode: mode, isDefault: false)) self.getNotificationSettingsRoomIdIsEncryptedIsOneToOneReturnValue = RoomNotificationSettingsProxyMock(with: .init(mode: mode, isDefault: false))
Task { Task {
self.callbacks.send(.settingsDidChange) self.callbacks.send(.settingsDidChange)
} }
} }
restoreDefaultNotificationModeRoomIdClosure = { [weak self] _ in restoreDefaultNotificationModeRoomIdClosure = { [weak self] _ in
guard let self else { return } 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 { Task {
self.callbacks.send(.settingsDidChange) self.callbacks.send(.settingsDidChange)
} }
@@ -195,7 +195,7 @@ class RoomDetailsScreenViewModel: RoomDetailsScreenViewModelType, RoomDetailsScr
do { do {
let notificationMode = try await notificationSettingsProxy.getNotificationSettings(roomId: roomProxy.id, let notificationMode = try await notificationSettingsProxy.getNotificationSettings(roomId: roomProxy.id,
isEncrypted: roomProxy.isEncrypted, isEncrypted: roomProxy.isEncrypted,
activeMembersCount: UInt64(roomProxy.activeMembersCount)) isOneToOne: roomProxy.activeMembersCount == 2)
state.notificationSettingsState = .loaded(settings: notificationMode) state.notificationSettingsState = .loaded(settings: notificationMode)
} catch { } catch {
state.notificationSettingsState = .error state.notificationSettingsState = .error
@@ -213,7 +213,7 @@ class RoomDetailsScreenViewModel: RoomDetailsScreenViewModelType, RoomDetailsScr
do { do {
try await notificationSettingsProxy.unmuteRoom(roomId: roomProxy.id, try await notificationSettingsProxy.unmuteRoom(roomId: roomProxy.id,
isEncrypted: roomProxy.isEncrypted, isEncrypted: roomProxy.isEncrypted,
activeMembersCount: UInt64(roomProxy.activeMembersCount)) isOneToOne: roomProxy.activeMembersCount == 2)
} catch { } catch {
state.bindings.alertInfo = AlertInfo(id: .alert, state.bindings.alertInfo = AlertInfo(id: .alert,
title: L10n.commonError, title: L10n.commonError,
@@ -79,7 +79,7 @@ class RoomNotificationSettingsScreenViewModel: RoomNotificationSettingsScreenVie
do { do {
let settings = try await notificationSettingsProxy.getNotificationSettings(roomId: roomProxy.id, let settings = try await notificationSettingsProxy.getNotificationSettings(roomId: roomProxy.id,
isEncrypted: roomProxy.isEncrypted, isEncrypted: roomProxy.isEncrypted,
activeMembersCount: UInt64(roomProxy.activeMembersCount)) isOneToOne: roomProxy.activeMembersCount == 2)
guard !Task.isCancelled else { return } guard !Task.isCancelled else { return }
state.notificationSettingsState = .loaded(settings: settings) state.notificationSettingsState = .loaded(settings: settings)
if !state.isRestoringDefautSetting { if !state.isRestoringDefautSetting {
@@ -121,15 +121,13 @@ class NotificationSettingsScreenViewModel: NotificationSettingsScreenViewModelTy
fetchSettingsTask = Task { fetchSettingsTask = Task {
// Group chats // Group chats
// A group chat is a chat having more than 2 active members // A group chat is a chat having more than 2 active members
let groupChatActiveMembers: UInt64 = 3 var groupChatsMode = await notificationSettingsProxy.getDefaultNotificationRoomMode(isEncrypted: false, isOneToOne: false)
var groupChatsMode = await notificationSettingsProxy.getDefaultNotificationRoomMode(isEncrypted: false, activeMembersCount: groupChatActiveMembers) let encryptedGroupChatsMode = await notificationSettingsProxy.getDefaultNotificationRoomMode(isEncrypted: true, isOneToOne: false)
let encryptedGroupChatsMode = await notificationSettingsProxy.getDefaultNotificationRoomMode(isEncrypted: true, activeMembersCount: groupChatActiveMembers)
// Direct chats // Direct chats
// A direct chat is a chat having exactly 2 active members // A direct chat is a chat having exactly 2 active members
let directChatActiveMembers: UInt64 = 2 var directChatsMode = await notificationSettingsProxy.getDefaultNotificationRoomMode(isEncrypted: false, isOneToOne: true)
var directChatsMode = await notificationSettingsProxy.getDefaultNotificationRoomMode(isEncrypted: false, activeMembersCount: directChatActiveMembers) let encryptedDirectChatsMode = await notificationSettingsProxy.getDefaultNotificationRoomMode(isEncrypted: true, isOneToOne: true)
let encryptedDirectChatsMode = await notificationSettingsProxy.getDefaultNotificationRoomMode(isEncrypted: true, activeMembersCount: directChatActiveMembers)
// Old clients were having specific settings for encrypted and unencrypted rooms, // 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`) // 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() let notificationCenter = UserNotificationCenterMock()
notificationCenter.authorizationStatusReturnValue = .notDetermined notificationCenter.authorizationStatusReturnValue = .notDetermined
let notificationSettingsProxy = NotificationSettingsProxyMock(with: .init()) let notificationSettingsProxy = NotificationSettingsProxyMock(with: .init())
notificationSettingsProxy.getDefaultNotificationRoomModeIsEncryptedActiveMembersCountClosure = { isEncrypted, activeMembersCount in notificationSettingsProxy.getDefaultNotificationRoomModeIsEncryptedIsOneToOneClosure = { isEncrypted, isOneToOne in
switch (isEncrypted, activeMembersCount) { switch (isEncrypted, isOneToOne) {
case (_, 2): case (_, true):
return .allMessages return .allMessages
default: default:
return .mentionsAndKeywordsOnly return .mentionsAndKeywordsOnly
@@ -46,8 +46,8 @@ final class NotificationSettingsProxy: NotificationSettingsProxyProtocol {
notificationSettings.setDelegate(delegate: WeakNotificationSettingsProxy(proxy: self)) notificationSettings.setDelegate(delegate: WeakNotificationSettingsProxy(proxy: self))
} }
func getNotificationSettings(roomId: String, isEncrypted: Bool, activeMembersCount: UInt64) async throws -> RoomNotificationSettingsProxyProtocol { func getNotificationSettings(roomId: String, isEncrypted: Bool, isOneToOne: Bool) async throws -> RoomNotificationSettingsProxyProtocol {
let roomMotificationSettings = try await notificationSettings.getRoomNotificationSettings(roomId: roomId, isEncrypted: isEncrypted, activeMembersCount: activeMembersCount) let roomMotificationSettings = try await notificationSettings.getRoomNotificationSettings(roomId: roomId, isEncrypted: isEncrypted, isOneToOne: isOneToOne)
return RoomNotificationSettingsProxy(roomNotificationSettings: roomMotificationSettings) return RoomNotificationSettingsProxy(roomNotificationSettings: roomMotificationSettings)
} }
@@ -68,8 +68,8 @@ final class NotificationSettingsProxy: NotificationSettingsProxyProtocol {
await updatedSettings() await updatedSettings()
} }
func getDefaultNotificationRoomMode(isEncrypted: Bool, activeMembersCount: UInt64) async -> RoomNotificationModeProxy { func getDefaultNotificationRoomMode(isEncrypted: Bool, isOneToOne: Bool) async -> RoomNotificationModeProxy {
let roomNotificationMode = await notificationSettings.getDefaultRoomNotificationMode(isEncrypted: isEncrypted, activeMembersCount: activeMembersCount) let roomNotificationMode = await notificationSettings.getDefaultRoomNotificationMode(isEncrypted: isEncrypted, isOneToOne: isOneToOne)
return RoomNotificationModeProxy.from(roomNotificationMode: roomNotificationMode) return RoomNotificationModeProxy.from(roomNotificationMode: roomNotificationMode)
} }
@@ -85,11 +85,11 @@ final class NotificationSettingsProxy: NotificationSettingsProxyProtocol {
await notificationSettings.containsKeywordsRules() 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") let backgroundTask = await backgroundTaskService?.startBackgroundTask(withName: "unmuteRoom")
defer { backgroundTask?.stop() } 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() await updatedSettings()
} }
@@ -26,12 +26,12 @@ enum NotificationSettingsProxyCallback {
protocol NotificationSettingsProxyProtocol { protocol NotificationSettingsProxyProtocol {
var callbacks: PassthroughSubject<NotificationSettingsProxyCallback, Never> { get } 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 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 restoreDefaultNotificationMode(roomId: String) async throws
func containsKeywordsRules() async -> Bool 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 isRoomMentionEnabled() async throws -> Bool
func setRoomMentionEnabled(enabled: Bool) async throws func setRoomMentionEnabled(enabled: Bool) async throws
func isUserMentionEnabled() async throws -> Bool func isUserMentionEnabled() async throws -> Bool
@@ -73,7 +73,7 @@ class RoomSummaryProvider: RoomSummaryProviderProtocol {
self.roomList = roomList self.roomList = roomList
do { 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 } guard let self else { return }
MXLog.info("\(name): Received list update") MXLog.info("\(name): Received list update")
diffsPublisher.send(updates) diffsPublisher.send(updates)
@@ -34,7 +34,7 @@ class NotificationSettingsScreenViewModelTests: XCTestCase {
userNotificationCenter.authorizationStatusReturnValue = .authorized userNotificationCenter.authorizationStatusReturnValue = .authorized
appSettings = AppSettings() appSettings = AppSettings()
notificationSettingsProxy = NotificationSettingsProxyMock(with: NotificationSettingsProxyMockConfiguration()) notificationSettingsProxy = NotificationSettingsProxyMock(with: NotificationSettingsProxyMockConfiguration())
notificationSettingsProxy.getDefaultNotificationRoomModeIsEncryptedActiveMembersCountReturnValue = .allMessages notificationSettingsProxy.getDefaultNotificationRoomModeIsEncryptedIsOneToOneReturnValue = .allMessages
notificationSettingsProxy.isRoomMentionEnabledReturnValue = true notificationSettingsProxy.isRoomMentionEnabledReturnValue = true
notificationSettingsProxy.isCallEnabledReturnValue = true notificationSettingsProxy.isCallEnabledReturnValue = true
@@ -58,9 +58,9 @@ class NotificationSettingsScreenViewModelTests: XCTestCase {
} }
func testFetchSettings() async throws { func testFetchSettings() async throws {
notificationSettingsProxy.getDefaultNotificationRoomModeIsEncryptedActiveMembersCountClosure = { isEncrypted, activeMembersCount in notificationSettingsProxy.getDefaultNotificationRoomModeIsEncryptedIsOneToOneClosure = { isEncrypted, isOneToOne in
switch (isEncrypted, activeMembersCount) { switch (isEncrypted, isOneToOne) {
case (_, 2): case (_, true):
return .allMessages return .allMessages
case (_, _): case (_, _):
return .mentionsAndKeywordsOnly return .mentionsAndKeywordsOnly
@@ -71,7 +71,7 @@ class NotificationSettingsScreenViewModelTests: XCTestCase {
notificationSettingsProxy.callbacks.send(.settingsDidChange) notificationSettingsProxy.callbacks.send(.settingsDidChange)
try await deferred.fulfill() try await deferred.fulfill()
XCTAssertEqual(notificationSettingsProxy.getDefaultNotificationRoomModeIsEncryptedActiveMembersCountCallsCount, 4) XCTAssertEqual(notificationSettingsProxy.getDefaultNotificationRoomModeIsEncryptedIsOneToOneCallsCount, 4)
XCTAssert(notificationSettingsProxy.isRoomMentionEnabledCalled) XCTAssert(notificationSettingsProxy.isRoomMentionEnabledCalled)
XCTAssert(notificationSettingsProxy.isCallEnabledCalled) XCTAssert(notificationSettingsProxy.isCallEnabledCalled)
@@ -82,11 +82,11 @@ class NotificationSettingsScreenViewModelTests: XCTestCase {
} }
func testInconsistentGroupChatsSettings() async throws { func testInconsistentGroupChatsSettings() async throws {
notificationSettingsProxy.getDefaultNotificationRoomModeIsEncryptedActiveMembersCountClosure = { isEncrypted, activeMembersCount in notificationSettingsProxy.getDefaultNotificationRoomModeIsEncryptedIsOneToOneClosure = { isEncrypted, isOneToOne in
switch (isEncrypted, activeMembersCount) { switch (isEncrypted, isOneToOne) {
case (true, 3): case (true, false):
return .allMessages return .allMessages
case (false, 3): case (false, false):
return .mentionsAndKeywordsOnly return .mentionsAndKeywordsOnly
default: default:
return .allMessages return .allMessages
@@ -103,11 +103,11 @@ class NotificationSettingsScreenViewModelTests: XCTestCase {
} }
func testInconsistentDirectChatsSettings() async throws { func testInconsistentDirectChatsSettings() async throws {
notificationSettingsProxy.getDefaultNotificationRoomModeIsEncryptedActiveMembersCountClosure = { isEncrypted, activeMembersCount in notificationSettingsProxy.getDefaultNotificationRoomModeIsEncryptedIsOneToOneClosure = { isEncrypted, isOneToOne in
switch (isEncrypted, activeMembersCount) { switch (isEncrypted, isOneToOne) {
case (true, 2): case (true, true):
return .allMessages return .allMessages
case (false, 2): case (false, true):
return .mentionsAndKeywordsOnly return .mentionsAndKeywordsOnly
default: default:
return .allMessages return .allMessages
@@ -381,7 +381,7 @@ class RoomDetailsScreenViewModelTests: XCTestCase {
// MARK: - Notifications // MARK: - Notifications
func testNotificationLoadingSettingsFailure() async throws { func testNotificationLoadingSettingsFailure() async throws {
notificationSettingsProxyMock.getNotificationSettingsRoomIdIsEncryptedActiveMembersCountThrowableError = NotificationSettingsError.Generic(message: "error") notificationSettingsProxyMock.getNotificationSettingsRoomIdIsEncryptedIsOneToOneThrowableError = NotificationSettingsError.Generic(message: "error")
viewModel = RoomDetailsScreenViewModel(accountUserID: "@owner:somewhere.com", viewModel = RoomDetailsScreenViewModel(accountUserID: "@owner:somewhere.com",
roomProxy: roomProxyMock, roomProxy: roomProxyMock,
mediaProvider: MockMediaProvider(), mediaProvider: MockMediaProvider(),
@@ -403,7 +403,7 @@ class RoomDetailsScreenViewModelTests: XCTestCase {
} }
func testNotificationDefaultMode() async throws { func testNotificationDefaultMode() async throws {
notificationSettingsProxyMock.getNotificationSettingsRoomIdIsEncryptedActiveMembersCountReturnValue = RoomNotificationSettingsProxyMock(with: .init(mode: .allMessages, isDefault: true)) notificationSettingsProxyMock.getNotificationSettingsRoomIdIsEncryptedIsOneToOneReturnValue = RoomNotificationSettingsProxyMock(with: .init(mode: .allMessages, isDefault: true))
let deferred = deferFulfillment(context.$viewState.map(\.notificationSettingsState).first(where: \.isLoaded)) let deferred = deferFulfillment(context.$viewState.map(\.notificationSettingsState).first(where: \.isLoaded))
notificationSettingsProxyMock.callbacks.send(.settingsDidChange) notificationSettingsProxyMock.callbacks.send(.settingsDidChange)
try await deferred.fulfill() try await deferred.fulfill()
@@ -412,7 +412,7 @@ class RoomDetailsScreenViewModelTests: XCTestCase {
} }
func testNotificationCustomMode() async throws { func testNotificationCustomMode() async throws {
notificationSettingsProxyMock.getNotificationSettingsRoomIdIsEncryptedActiveMembersCountReturnValue = RoomNotificationSettingsProxyMock(with: .init(mode: .allMessages, isDefault: false)) notificationSettingsProxyMock.getNotificationSettingsRoomIdIsEncryptedIsOneToOneReturnValue = RoomNotificationSettingsProxyMock(with: .init(mode: .allMessages, isDefault: false))
let deferred = deferFulfillment(context.$viewState.map(\.notificationSettingsState).first(where: \.isCustom)) let deferred = deferFulfillment(context.$viewState.map(\.notificationSettingsState).first(where: \.isCustom))
notificationSettingsProxyMock.callbacks.send(.settingsDidChange) notificationSettingsProxyMock.callbacks.send(.settingsDidChange)
try await deferred.fulfill() try await deferred.fulfill()
@@ -421,7 +421,7 @@ class RoomDetailsScreenViewModelTests: XCTestCase {
} }
func testNotificationRoomMuted() async throws { func testNotificationRoomMuted() async throws {
notificationSettingsProxyMock.getNotificationSettingsRoomIdIsEncryptedActiveMembersCountReturnValue = RoomNotificationSettingsProxyMock(with: .init(mode: .mute, isDefault: false)) notificationSettingsProxyMock.getNotificationSettingsRoomIdIsEncryptedIsOneToOneReturnValue = RoomNotificationSettingsProxyMock(with: .init(mode: .mute, isDefault: false))
let deferred = deferFulfillment(context.$viewState.map(\.notificationSettingsState).first(where: \.isLoaded)) let deferred = deferFulfillment(context.$viewState.map(\.notificationSettingsState).first(where: \.isLoaded))
notificationSettingsProxyMock.callbacks.send(.settingsDidChange) notificationSettingsProxyMock.callbacks.send(.settingsDidChange)
try await deferred.fulfill() try await deferred.fulfill()
@@ -431,7 +431,7 @@ class RoomDetailsScreenViewModelTests: XCTestCase {
} }
func testNotificationRoomNotMuted() async throws { func testNotificationRoomNotMuted() async throws {
notificationSettingsProxyMock.getNotificationSettingsRoomIdIsEncryptedActiveMembersCountReturnValue = RoomNotificationSettingsProxyMock(with: .init(mode: .mentionsAndKeywordsOnly, isDefault: false)) notificationSettingsProxyMock.getNotificationSettingsRoomIdIsEncryptedIsOneToOneReturnValue = RoomNotificationSettingsProxyMock(with: .init(mode: .mentionsAndKeywordsOnly, isDefault: false))
let deferred = deferFulfillment(context.$viewState.map(\.notificationSettingsState).first(where: \.isLoaded)) let deferred = deferFulfillment(context.$viewState.map(\.notificationSettingsState).first(where: \.isLoaded))
notificationSettingsProxyMock.callbacks.send(.settingsDidChange) notificationSettingsProxyMock.callbacks.send(.settingsDidChange)
try await deferred.fulfill() try await deferred.fulfill()
@@ -444,7 +444,7 @@ class RoomDetailsScreenViewModelTests: XCTestCase {
try await testNotificationRoomMuted() try await testNotificationRoomMuted()
let expectation = expectation(description: #function) let expectation = expectation(description: #function)
notificationSettingsProxyMock.unmuteRoomRoomIdIsEncryptedActiveMembersCountClosure = { _, _, _ in notificationSettingsProxyMock.unmuteRoomRoomIdIsEncryptedIsOneToOneClosure = { _, _, _ in
defer { defer {
expectation.fulfill() expectation.fulfill()
} }
@@ -495,7 +495,7 @@ class RoomDetailsScreenViewModelTests: XCTestCase {
let expectation = expectation(description: #function) let expectation = expectation(description: #function)
notificationSettingsProxyMock.setNotificationModeRoomIdModeClosure = { [weak notificationSettingsProxyMock] _, mode in notificationSettingsProxyMock.setNotificationModeRoomIdModeClosure = { [weak notificationSettingsProxyMock] _, mode in
notificationSettingsProxyMock?.getNotificationSettingsRoomIdIsEncryptedActiveMembersCountReturnValue = RoomNotificationSettingsProxyMock(with: .init(mode: mode, isDefault: false)) notificationSettingsProxyMock?.getNotificationSettingsRoomIdIsEncryptedIsOneToOneReturnValue = RoomNotificationSettingsProxyMock(with: .init(mode: mode, isDefault: false))
expectation.fulfill() expectation.fulfill()
} }
context.send(viewAction: .processToogleMuteNotifications) context.send(viewAction: .processToogleMuteNotifications)
@@ -521,8 +521,8 @@ class RoomDetailsScreenViewModelTests: XCTestCase {
try await testNotificationRoomMuted() try await testNotificationRoomMuted()
let expectation = expectation(description: #function) let expectation = expectation(description: #function)
notificationSettingsProxyMock.unmuteRoomRoomIdIsEncryptedActiveMembersCountClosure = { [weak notificationSettingsProxyMock] _, _, _ in notificationSettingsProxyMock.unmuteRoomRoomIdIsEncryptedIsOneToOneClosure = { [weak notificationSettingsProxyMock] _, _, _ in
notificationSettingsProxyMock?.getNotificationSettingsRoomIdIsEncryptedActiveMembersCountReturnValue = RoomNotificationSettingsProxyMock(with: .init(mode: .allMessages, isDefault: false)) notificationSettingsProxyMock?.getNotificationSettingsRoomIdIsEncryptedIsOneToOneReturnValue = RoomNotificationSettingsProxyMock(with: .init(mode: .allMessages, isDefault: false))
expectation.fulfill() expectation.fulfill()
} }
context.send(viewAction: .processToogleMuteNotifications) context.send(viewAction: .processToogleMuteNotifications)
@@ -34,7 +34,7 @@ class RoomNotificationSettingsScreenViewModelTests: XCTestCase {
} }
func testInitialStateDefaultMode() async throws { func testInitialStateDefaultMode() async throws {
notificationSettingsProxyMock.getNotificationSettingsRoomIdIsEncryptedActiveMembersCountReturnValue = RoomNotificationSettingsProxyMock(with: .init(mode: .mentionsAndKeywordsOnly, isDefault: true)) notificationSettingsProxyMock.getNotificationSettingsRoomIdIsEncryptedIsOneToOneReturnValue = RoomNotificationSettingsProxyMock(with: .init(mode: .mentionsAndKeywordsOnly, isDefault: true))
viewModel = RoomNotificationSettingsScreenViewModel(notificationSettingsProxy: notificationSettingsProxyMock, viewModel = RoomNotificationSettingsScreenViewModel(notificationSettingsProxy: notificationSettingsProxyMock,
roomProxy: roomProxyMock) roomProxy: roomProxyMock)
let deferred = deferFulfillment(context.$viewState.map(\.notificationSettingsState) let deferred = deferFulfillment(context.$viewState.map(\.notificationSettingsState)
@@ -46,7 +46,7 @@ class RoomNotificationSettingsScreenViewModelTests: XCTestCase {
} }
func testInitialStateCustomMode() async throws { func testInitialStateCustomMode() async throws {
notificationSettingsProxyMock.getNotificationSettingsRoomIdIsEncryptedActiveMembersCountReturnValue = RoomNotificationSettingsProxyMock(with: .init(mode: .mentionsAndKeywordsOnly, isDefault: false)) notificationSettingsProxyMock.getNotificationSettingsRoomIdIsEncryptedIsOneToOneReturnValue = RoomNotificationSettingsProxyMock(with: .init(mode: .mentionsAndKeywordsOnly, isDefault: false))
viewModel = RoomNotificationSettingsScreenViewModel(notificationSettingsProxy: notificationSettingsProxyMock, viewModel = RoomNotificationSettingsScreenViewModel(notificationSettingsProxy: notificationSettingsProxyMock,
roomProxy: roomProxyMock) roomProxy: roomProxyMock)
let deferred = deferFulfillment(context.$viewState.map(\.notificationSettingsState) let deferred = deferFulfillment(context.$viewState.map(\.notificationSettingsState)
@@ -58,7 +58,7 @@ class RoomNotificationSettingsScreenViewModelTests: XCTestCase {
} }
func testInitialStateFailure() async throws { func testInitialStateFailure() async throws {
notificationSettingsProxyMock.getNotificationSettingsRoomIdIsEncryptedActiveMembersCountThrowableError = NotificationSettingsError.Generic(message: "error") notificationSettingsProxyMock.getNotificationSettingsRoomIdIsEncryptedIsOneToOneThrowableError = NotificationSettingsError.Generic(message: "error")
viewModel = RoomNotificationSettingsScreenViewModel(notificationSettingsProxy: notificationSettingsProxyMock, viewModel = RoomNotificationSettingsScreenViewModel(notificationSettingsProxy: notificationSettingsProxyMock,
roomProxy: roomProxyMock) roomProxy: roomProxyMock)
let deferred = deferFulfillment(context.$viewState.map(\.notificationSettingsState) let deferred = deferFulfillment(context.$viewState.map(\.notificationSettingsState)
@@ -75,7 +75,7 @@ class RoomNotificationSettingsScreenViewModelTests: XCTestCase {
} }
func testToggleAllCustomSettingOff() async throws { func testToggleAllCustomSettingOff() async throws {
notificationSettingsProxyMock.getNotificationSettingsRoomIdIsEncryptedActiveMembersCountReturnValue = RoomNotificationSettingsProxyMock(with: .init(mode: .mentionsAndKeywordsOnly, isDefault: false)) notificationSettingsProxyMock.getNotificationSettingsRoomIdIsEncryptedIsOneToOneReturnValue = RoomNotificationSettingsProxyMock(with: .init(mode: .mentionsAndKeywordsOnly, isDefault: false))
viewModel = RoomNotificationSettingsScreenViewModel(notificationSettingsProxy: notificationSettingsProxyMock, viewModel = RoomNotificationSettingsScreenViewModel(notificationSettingsProxy: notificationSettingsProxyMock,
roomProxy: roomProxyMock) roomProxy: roomProxyMock)
let deferred = deferFulfillment(context.$viewState.map(\.notificationSettingsState) let deferred = deferFulfillment(context.$viewState.map(\.notificationSettingsState)
@@ -96,7 +96,7 @@ class RoomNotificationSettingsScreenViewModelTests: XCTestCase {
} }
func testToggleAllCustomSettingOffOn() async throws { func testToggleAllCustomSettingOffOn() async throws {
notificationSettingsProxyMock.getNotificationSettingsRoomIdIsEncryptedActiveMembersCountReturnValue = RoomNotificationSettingsProxyMock(with: .init(mode: .mentionsAndKeywordsOnly, isDefault: true)) notificationSettingsProxyMock.getNotificationSettingsRoomIdIsEncryptedIsOneToOneReturnValue = RoomNotificationSettingsProxyMock(with: .init(mode: .mentionsAndKeywordsOnly, isDefault: true))
viewModel = RoomNotificationSettingsScreenViewModel(notificationSettingsProxy: notificationSettingsProxyMock, viewModel = RoomNotificationSettingsScreenViewModel(notificationSettingsProxy: notificationSettingsProxyMock,
roomProxy: roomProxyMock) roomProxy: roomProxyMock)
var deferred = deferFulfillment(context.$viewState.map(\.notificationSettingsState).first(where: \.isLoaded)) var deferred = deferFulfillment(context.$viewState.map(\.notificationSettingsState).first(where: \.isLoaded))
@@ -114,7 +114,7 @@ class RoomNotificationSettingsScreenViewModelTests: XCTestCase {
} }
func testSetCustomMode() async throws { func testSetCustomMode() async throws {
notificationSettingsProxyMock.getNotificationSettingsRoomIdIsEncryptedActiveMembersCountReturnValue = RoomNotificationSettingsProxyMock(with: .init(mode: .mentionsAndKeywordsOnly, isDefault: false)) notificationSettingsProxyMock.getNotificationSettingsRoomIdIsEncryptedIsOneToOneReturnValue = RoomNotificationSettingsProxyMock(with: .init(mode: .mentionsAndKeywordsOnly, isDefault: false))
viewModel = RoomNotificationSettingsScreenViewModel(notificationSettingsProxy: notificationSettingsProxyMock, viewModel = RoomNotificationSettingsScreenViewModel(notificationSettingsProxy: notificationSettingsProxyMock,
roomProxy: roomProxyMock) roomProxy: roomProxyMock)
let deferredState = deferFulfillment(context.$viewState.map(\.notificationSettingsState).first(where: \.isLoaded)) let deferredState = deferFulfillment(context.$viewState.map(\.notificationSettingsState).first(where: \.isLoaded))
+1 -1
View File
@@ -44,7 +44,7 @@ include:
packages: packages:
MatrixRustSDK: MatrixRustSDK:
url: https://github.com/matrix-org/matrix-rust-components-swift url: https://github.com/matrix-org/matrix-rust-components-swift
exactVersion: 1.0.105-alpha exactVersion: 1.0.106-alpha
# path: ../matrix-rust-sdk # path: ../matrix-rust-sdk
DesignKit: DesignKit:
path: DesignKit path: DesignKit