mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-04 01:20:12 +00:00
Bump the RustSDK to v1.0.67 (#3512)
* Bump the RustSDK to v1.0.67 * PR comments --------- Co-authored-by: Doug <douglase@element.io>
This commit is contained in:
@@ -315,47 +315,22 @@ class JoinedRoomProxy: JoinedRoomProxyProtocol {
|
||||
}
|
||||
}
|
||||
|
||||
func resend(itemID: TimelineItemIdentifier) async -> Result<Void, RoomProxyError> {
|
||||
guard let transactionID = itemID.transactionID else {
|
||||
MXLog.error("Attempting to resend an item that has no transaction ID: \(itemID)")
|
||||
return .failure(.missingTransactionID)
|
||||
}
|
||||
|
||||
func ignoreDeviceTrustAndResend(devices: [String: [String]], sendHandle: SendHandleProxy) async -> Result<Void, RoomProxyError> {
|
||||
do {
|
||||
try await room.tryResend(transactionId: transactionID)
|
||||
try await room.ignoreDeviceTrustAndResend(devices: devices, sendHandle: sendHandle.underlyingHandle)
|
||||
return .success(())
|
||||
} catch {
|
||||
MXLog.error("Failed resending \(transactionID) with error: \(error)")
|
||||
MXLog.error("Failed trusting devices \(devices) and resending \(sendHandle.itemID) with error: \(error)")
|
||||
return .failure(.sdkError(error))
|
||||
}
|
||||
}
|
||||
|
||||
func ignoreDeviceTrustAndResend(devices: [String: [String]], itemID: TimelineItemIdentifier) async -> Result<Void, RoomProxyError> {
|
||||
guard let transactionID = itemID.transactionID else {
|
||||
MXLog.error("Attempting to resend an item that has no transaction ID: \(itemID)")
|
||||
return .failure(.missingTransactionID)
|
||||
}
|
||||
|
||||
func withdrawVerificationAndResend(userIDs: [String], sendHandle: SendHandleProxy) async -> Result<Void, RoomProxyError> {
|
||||
do {
|
||||
try await room.ignoreDeviceTrustAndResend(devices: devices, transactionId: transactionID)
|
||||
try await room.withdrawVerificationAndResend(userIds: userIDs, sendHandle: sendHandle.underlyingHandle)
|
||||
return .success(())
|
||||
} catch {
|
||||
MXLog.error("Failed trusting devices \(devices) and resending \(transactionID) with error: \(error)")
|
||||
return .failure(.sdkError(error))
|
||||
}
|
||||
}
|
||||
|
||||
func withdrawVerificationAndResend(userIDs: [String], itemID: TimelineItemIdentifier) async -> Result<Void, RoomProxyError> {
|
||||
guard let transactionID = itemID.transactionID else {
|
||||
MXLog.error("Attempting to resend an item that has no transaction ID: \(itemID)")
|
||||
return .failure(.missingTransactionID)
|
||||
}
|
||||
|
||||
do {
|
||||
try await room.withdrawVerificationAndResend(userIds: userIDs, transactionId: transactionID)
|
||||
return .success(())
|
||||
} catch {
|
||||
MXLog.error("Failed withdrawing verification of \(userIDs) and resending \(transactionID) with error: \(error)")
|
||||
MXLog.error("Failed withdrawing verification of \(userIDs) and resending \(sendHandle.itemID) with error: \(error)")
|
||||
return .failure(.sdkError(error))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -97,11 +97,9 @@ protocol JoinedRoomProxyProtocol: RoomProxyProtocol {
|
||||
/// https://spec.matrix.org/v1.9/client-server-api/#typing-notifications
|
||||
@discardableResult func sendTypingNotification(isTyping: Bool) async -> Result<Void, RoomProxyError>
|
||||
|
||||
func resend(itemID: TimelineItemIdentifier) async -> Result<Void, RoomProxyError>
|
||||
func ignoreDeviceTrustAndResend(devices: [String: [String]], sendHandle: SendHandleProxy) async -> Result<Void, RoomProxyError>
|
||||
|
||||
func ignoreDeviceTrustAndResend(devices: [String: [String]], itemID: TimelineItemIdentifier) async -> Result<Void, RoomProxyError>
|
||||
|
||||
func withdrawVerificationAndResend(userIDs: [String], itemID: TimelineItemIdentifier) async -> Result<Void, RoomProxyError>
|
||||
func withdrawVerificationAndResend(userIDs: [String], sendHandle: SendHandleProxy) async -> Result<Void, RoomProxyError>
|
||||
|
||||
// MARK: - Room Flags
|
||||
|
||||
|
||||
@@ -35,7 +35,7 @@ struct RoomEventStringBuilder {
|
||||
case .redactedMessage:
|
||||
return prefix(L10n.commonMessageRemoved, with: displayName)
|
||||
case .sticker:
|
||||
if messageEventStringBuilder.prefix == .messageType {
|
||||
if messageEventStringBuilder.destination == .pinnedEvent {
|
||||
var string = AttributedString(L10n.commonSticker)
|
||||
string.bold()
|
||||
return string
|
||||
@@ -49,7 +49,7 @@ struct RoomEventStringBuilder {
|
||||
return stateEventStringBuilder
|
||||
.buildString(for: state, sender: sender, isOutgoing: isOutgoing)
|
||||
.map(AttributedString.init)
|
||||
case .roomMembership(let userID, let displayName, let change):
|
||||
case .roomMembership(let userID, let displayName, let change, _):
|
||||
return stateEventStringBuilder
|
||||
.buildString(for: change, memberUserID: userID, memberDisplayName: displayName, sender: sender, isOutgoing: isOutgoing)
|
||||
.map(AttributedString.init)
|
||||
@@ -63,7 +63,7 @@ struct RoomEventStringBuilder {
|
||||
memberIsYou: isOutgoing)
|
||||
.map(AttributedString.init)
|
||||
case .poll(let question, _, _, _, _, _, _):
|
||||
if messageEventStringBuilder.prefix == .messageType {
|
||||
if messageEventStringBuilder.destination == .pinnedEvent {
|
||||
let questionPlaceholder = "{question}"
|
||||
var finalString = AttributedString(L10n.commonPollSummary(questionPlaceholder))
|
||||
finalString.bold()
|
||||
@@ -96,7 +96,7 @@ struct RoomEventStringBuilder {
|
||||
RoomEventStringBuilder(stateEventStringBuilder: .init(userID: userID,
|
||||
shouldDisambiguateDisplayNames: false),
|
||||
messageEventStringBuilder: .init(attributedStringBuilder: AttributedStringBuilder(cacheKey: "pinnedEvents", mentionBuilder: PlainMentionBuilder()),
|
||||
prefix: .messageType),
|
||||
destination: .pinnedEvent),
|
||||
shouldDisambiguateDisplayNames: false,
|
||||
shouldPrefixSenderName: false)
|
||||
}
|
||||
|
||||
@@ -9,42 +9,46 @@ import Foundation
|
||||
import MatrixRustSDK
|
||||
|
||||
struct RoomMessageEventStringBuilder {
|
||||
enum Prefix {
|
||||
case senderName
|
||||
case messageType
|
||||
case none
|
||||
enum Destination {
|
||||
/// Strings show on the room list as the last message
|
||||
/// The sender will be prefixed in bold
|
||||
case roomList
|
||||
/// Events pinned to the banner on the top of the timeline
|
||||
/// The message type will be prefixed in bold
|
||||
case pinnedEvent
|
||||
/// Shown in push notifications
|
||||
/// No prefix
|
||||
case notification
|
||||
}
|
||||
|
||||
let attributedStringBuilder: AttributedStringBuilderProtocol
|
||||
let prefix: Prefix
|
||||
let destination: Destination
|
||||
|
||||
func buildAttributedString(for messageType: MessageType, senderDisplayName: String) -> AttributedString {
|
||||
let message: AttributedString
|
||||
switch messageType {
|
||||
// Message types that don't need a prefix.
|
||||
case .emote(content: let content):
|
||||
if let attributedMessage = attributedMessageFrom(formattedBody: content.formatted) {
|
||||
return AttributedString(L10n.commonEmote(senderDisplayName, String(attributedMessage.characters)))
|
||||
} else {
|
||||
return AttributedString(L10n.commonEmote(senderDisplayName, content.body))
|
||||
}
|
||||
// Message types that should be prefixed with the sender's name.
|
||||
case .audio(content: let content):
|
||||
let isVoiceMessage = content.voice != nil
|
||||
var content = AttributedString(isVoiceMessage ? L10n.commonVoiceMessage : L10n.commonAudio)
|
||||
if prefix == .messageType {
|
||||
if destination == .pinnedEvent {
|
||||
content.bold()
|
||||
}
|
||||
message = content
|
||||
case .image(let content):
|
||||
message = prefix == .messageType ? prefix(AttributedString(content.body), with: L10n.commonImage) : AttributedString("\(L10n.commonImage) - \(content.body)")
|
||||
message = buildMessage(for: destination, caption: content.caption, type: L10n.commonImage)
|
||||
case .video(let content):
|
||||
message = prefix == .messageType ? prefix(AttributedString(content.body), with: L10n.commonVideo) : AttributedString("\(L10n.commonVideo) - \(content.body)")
|
||||
message = buildMessage(for: destination, caption: content.caption, type: L10n.commonVideo)
|
||||
case .file(let content):
|
||||
message = prefix == .messageType ? prefix(AttributedString(content.body), with: L10n.commonFile) : AttributedString("\(L10n.commonFile) - \(content.body)")
|
||||
message = buildMessage(for: destination, caption: content.caption, type: L10n.commonFile)
|
||||
case .location:
|
||||
var content = AttributedString(L10n.commonSharedLocation)
|
||||
if prefix == .messageType {
|
||||
if destination == .pinnedEvent {
|
||||
content.bold()
|
||||
}
|
||||
message = content
|
||||
@@ -64,13 +68,25 @@ struct RoomMessageEventStringBuilder {
|
||||
message = AttributedString(body)
|
||||
}
|
||||
|
||||
if prefix == .senderName {
|
||||
if destination == .roomList {
|
||||
return prefix(message, with: senderDisplayName)
|
||||
} else {
|
||||
return message
|
||||
}
|
||||
}
|
||||
|
||||
private func buildMessage(for destination: Destination, caption: String?, type: String) -> AttributedString {
|
||||
guard let caption else {
|
||||
return AttributedString(type)
|
||||
}
|
||||
|
||||
if destination == .pinnedEvent {
|
||||
return prefix(AttributedString(caption), with: type)
|
||||
} else {
|
||||
return AttributedString("\(type) - \(caption)")
|
||||
}
|
||||
}
|
||||
|
||||
private func prefix(_ eventSummary: AttributedString, with textToBold: String) -> AttributedString {
|
||||
let attributedEventSummary = AttributedString(eventSummary.string.trimmingCharacters(in: .whitespacesAndNewlines))
|
||||
|
||||
|
||||
Reference in New Issue
Block a user