mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-03 06:55:59 +00:00
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:
@@ -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)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user