Use server name from user id function (#6082)

update sdk and use the new server from user id function from the sdk
This commit is contained in:
Mauro
2026-08-27 16:28:40 +02:00
committed by GitHub
parent efefd549a2
commit 9f7e30820b
8 changed files with 31 additions and 18 deletions
@@ -6,6 +6,7 @@
//
import Foundation
import MatrixRustSDK
class ClassicAppAccountManager {
private let cacheFolder: URL
@@ -64,7 +65,7 @@ class ClassicAppAccountManager {
let userID = mxAccount.userID
let user = loadUser(for: mxAccount) // We need an MXUser for the profile as MXAccount doesn't contain that data.
guard let serverName = serverName(for: userID) else { return nil }
guard let serverName = try? serverNameFromUserId(userId: userID) else { return nil }
return ClassicAppAccount(userID: userID,
displayName: user?.displayName,
@@ -103,13 +104,6 @@ class ClassicAppAccountManager {
}
}
/// The server name extracted from the user's ID.
private func serverName(for userID: String) -> String? {
let components = userID.components(separatedBy: ":")
guard components.count > 1 else { return nil }
return components[1] // Directly use [1] as .last may be the port number.
}
// MARK: - File URLs
private static let matrixKitFolder = "MatrixKit"
@@ -212,7 +212,7 @@ extension JoinedRoomProxyProtocol {
func knownServerNames(maxCount: Int) -> any Sequence<String> {
membersPublisher.value
.prefix(1000) // No need to go crazy here…
.compactMap { $0.userID.split(separator: ":").last.map(String.init) }
.compactMap { try? serverNameFromUserId(userId: $0.userID) }
.uniqued()
.prefix(maxCount)
}