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:
Stefan Ceriu
2024-04-01 10:07:30 +03:00
parent 2e6c5c036a
commit 834a830952
8 changed files with 104 additions and 26 deletions
@@ -38,7 +38,7 @@ struct RoomDetailsScreenViewState: BindableState {
let isEncrypted: Bool
let isDirect: Bool
let permalink: URL?
var permalink: URL?
var topic: AttributedString?
var topicSummary: AttributedString?
@@ -59,7 +59,6 @@ class RoomDetailsScreenViewModel: RoomDetailsScreenViewModelType, RoomDetailsScr
super.init(initialViewState: .init(details: roomProxy.details,
isEncrypted: roomProxy.isEncrypted,
isDirect: roomProxy.isDirect,
permalink: roomProxy.permalink,
topic: topic,
topicSummary: topic?.unattributedStringByReplacingNewlinesWithSpaces(),
joinedMembersCount: roomProxy.joinedMembersCount,
@@ -67,6 +66,12 @@ class RoomDetailsScreenViewModel: RoomDetailsScreenViewModelType, RoomDetailsScr
bindings: .init()),
imageProvider: mediaProvider)
Task {
if case let .success(permalinkURL) = await roomProxy.matrixToPermalink() {
state.permalink = permalinkURL
}
}
updateRoomInfo()
Task { await updatePowerLevelPermissions() }
@@ -208,17 +208,18 @@ class RoomScreenInteractionHandler {
MXLog.error("Cannot edit item with id: \(timelineItem.id)")
}
case .copyPermalink:
do {
guard let eventID = eventTimelineItem.id.eventID else {
actionsSubject.send(.displayError(.alert(L10n.errorFailedCreatingThePermalink)))
break
}
let permalink = try PermalinkBuilder.permalinkTo(eventIdentifier: eventID, roomIdentifier: timelineController.roomID,
baseURL: appSettings.permalinkBaseURL)
UIPasteboard.general.url = permalink
} catch {
guard let eventID = eventTimelineItem.id.eventID else {
actionsSubject.send(.displayError(.alert(L10n.errorFailedCreatingThePermalink)))
return
}
Task {
guard case let .success(permalinkURL) = await roomProxy.matrixToEventPermalink(eventID) else {
actionsSubject.send(.displayError(.alert(L10n.errorFailedCreatingThePermalink)))
return
}
UIPasteboard.general.url = permalinkURL
}
case .redact:
Task {