Improve how alias settings are handled, add unit tests (#3686)

This commit is contained in:
Stefan Ceriu
2025-01-20 15:43:47 +02:00
committed by GitHub
parent 13e66062ba
commit 0fd8df52ab
10 changed files with 144 additions and 24 deletions
@@ -79,8 +79,18 @@ class SecurityAndPrivacyScreenViewModel: SecurityAndPrivacyScreenViewModelType,
}
.store(in: &cancellables)
let userIDServerName = clientProxy.userIDServerName
roomProxy.infoPublisher
.map(\.canonicalAlias)
.compactMap { roomInfo in
guard let userIDServerName else {
return nil
}
// Give priority to aliases from the current user's homeserver as remote ones
// cannot be edited.
return roomInfo.firstAliasMatching(serverName: userIDServerName, useFallback: true)
}
.removeDuplicates()
.receive(on: DispatchQueue.main)
.weakAssign(to: \.state.canonicalAlias, on: self)