mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-03 06:55:59 +00:00
Use RustSDK permalink builders:
- replace event permalinks on the room screen interaction handler - replace the one use don the room details screen - deprecate previous AttributedStringBuilder methods - there's more work required on the AttributedStringBuilder mentions handler before we can completely drop the iOS implementations
This commit is contained in:
@@ -528,6 +528,40 @@ class RoomProxy: RoomProxyProtocol {
|
||||
func elementCallWidgetDriver() -> ElementCallWidgetDriverProtocol {
|
||||
ElementCallWidgetDriver(room: room)
|
||||
}
|
||||
|
||||
// MARK: - Permalinks
|
||||
|
||||
func matrixToPermalink() async -> Result<URL, RoomProxyError> {
|
||||
do {
|
||||
let urlString = try await room.matrixToPermalink()
|
||||
|
||||
guard let url = URL(string: urlString) else {
|
||||
MXLog.error("Invalid permalink URL string: \(urlString)")
|
||||
return .failure(.generic("Invalid permalink URL string: \(urlString)"))
|
||||
}
|
||||
|
||||
return .success(url)
|
||||
} catch {
|
||||
MXLog.error("Failed creating permalink for roomID: \(id) with error: \(error)")
|
||||
return .failure(.generic(error.localizedDescription))
|
||||
}
|
||||
}
|
||||
|
||||
func matrixToEventPermalink(_ eventID: String) async -> Result<URL, RoomProxyError> {
|
||||
do {
|
||||
let urlString = try await room.matrixToEventPermalink(eventId: eventID)
|
||||
|
||||
guard let url = URL(string: urlString) else {
|
||||
MXLog.error("Invalid permalink URL string: \(urlString)")
|
||||
return .failure(.generic("Invalid permalink URL string: \(urlString)"))
|
||||
}
|
||||
|
||||
return .success(url)
|
||||
} catch {
|
||||
MXLog.error("Failed creating permalink for eventID: \(eventID) with error: \(error)")
|
||||
return .failure(.generic(error.localizedDescription))
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - Private
|
||||
|
||||
|
||||
@@ -19,6 +19,7 @@ import Foundation
|
||||
import MatrixRustSDK
|
||||
|
||||
enum RoomProxyError: Error, Equatable {
|
||||
case generic(String?)
|
||||
case failedRedactingEvent
|
||||
case failedReportingContent
|
||||
case failedRetrievingMember
|
||||
@@ -139,6 +140,12 @@ protocol RoomProxyProtocol {
|
||||
func canUserJoinCall(userID: String) async -> Result<Bool, RoomProxyError>
|
||||
|
||||
func elementCallWidgetDriver() -> ElementCallWidgetDriverProtocol
|
||||
|
||||
// MARK: - Permalinks
|
||||
|
||||
func matrixToPermalink() async -> Result<URL, RoomProxyError>
|
||||
|
||||
func matrixToEventPermalink(_ eventID: String) async -> Result<URL, RoomProxyError>
|
||||
}
|
||||
|
||||
extension RoomProxyProtocol {
|
||||
@@ -148,20 +155,7 @@ extension RoomProxyProtocol {
|
||||
avatarURL: avatarURL,
|
||||
canonicalAlias: canonicalAlias)
|
||||
}
|
||||
|
||||
var permalink: URL? {
|
||||
if let canonicalAlias, let link = try? PermalinkBuilder.permalinkTo(roomAlias: canonicalAlias,
|
||||
baseURL: ServiceLocator.shared.settings.permalinkBaseURL) {
|
||||
return link
|
||||
} else if let link = try? PermalinkBuilder.permalinkTo(roomIdentifier: id,
|
||||
baseURL: ServiceLocator.shared.settings.permalinkBaseURL) {
|
||||
return link
|
||||
} else {
|
||||
MXLog.error("Failed to build permalink for Room: \(id)")
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Avoids to duplicate the same logic around in the app
|
||||
// Probably this should be done in rust.
|
||||
var roomTitle: String {
|
||||
|
||||
Reference in New Issue
Block a user