Bump the SDK to v25.06.13 and add thread support to the ComposerDraftService

This commit is contained in:
Stefan Ceriu
2025-06-13 15:10:26 +03:00
committed by Stefan Ceriu
parent 719676875f
commit eaf14eaaac
10 changed files with 238 additions and 141 deletions
@@ -11,16 +11,20 @@ import MatrixRustSDK
final class ComposerDraftService: ComposerDraftServiceProtocol {
private let roomProxy: JoinedRoomProxyProtocol
private let threadRootEventID: String?
private let timelineItemfactory: RoomTimelineItemFactoryProtocol
private var volatileDraft: ComposerDraftProxy?
init(roomProxy: JoinedRoomProxyProtocol, timelineItemfactory: RoomTimelineItemFactoryProtocol) {
init(roomProxy: JoinedRoomProxyProtocol,
timelineItemfactory: RoomTimelineItemFactoryProtocol,
threadRootEventID: String?) {
self.roomProxy = roomProxy
self.threadRootEventID = threadRootEventID
self.timelineItemfactory = timelineItemfactory
}
func saveDraft(_ draft: ComposerDraftProxy) async -> Result<Void, ComposerDraftServiceError> {
switch await roomProxy.saveDraft(draft.toRust) {
switch await roomProxy.saveDraft(draft.toRust, threadRootEventID: threadRootEventID) {
case .success:
MXLog.info("Successfully saved draft")
return .success(())
@@ -31,7 +35,7 @@ final class ComposerDraftService: ComposerDraftServiceProtocol {
}
func loadDraft() async -> Result<ComposerDraftProxy?, ComposerDraftServiceError> {
switch await roomProxy.loadDraft() {
switch await roomProxy.loadDraft(threadRootEventID: threadRootEventID) {
case .success(let draft):
guard let draft else {
return .success(nil)
@@ -54,7 +58,7 @@ final class ComposerDraftService: ComposerDraftServiceProtocol {
}
func clearDraft() async -> Result<Void, ComposerDraftServiceError> {
switch await roomProxy.clearDraft() {
switch await roomProxy.clearDraft(threadRootEventID: threadRootEventID) {
case .success:
MXLog.info("Successfully cleared draft")
return .success(())
@@ -772,9 +772,9 @@ class JoinedRoomProxy: JoinedRoomProxyProtocol {
// MARK: - Drafts
func saveDraft(_ draft: ComposerDraft) async -> Result<Void, RoomProxyError> {
func saveDraft(_ draft: ComposerDraft, threadRootEventID: String?) async -> Result<Void, RoomProxyError> {
do {
try await room.saveComposerDraft(draft: draft)
try await room.saveComposerDraft(draft: draft, threadRoot: threadRootEventID)
return .success(())
} catch {
MXLog.error("Failed saving draft with error: \(error)")
@@ -782,18 +782,18 @@ class JoinedRoomProxy: JoinedRoomProxyProtocol {
}
}
func loadDraft() async -> Result<ComposerDraft?, RoomProxyError> {
func loadDraft(threadRootEventID: String?) async -> Result<ComposerDraft?, RoomProxyError> {
do {
return try await .success(room.loadComposerDraft())
return try await .success(room.loadComposerDraft(threadRoot: threadRootEventID))
} catch {
MXLog.error("Failed restoring draft with error: \(error)")
return .failure(.sdkError(error))
}
}
func clearDraft() async -> Result<Void, RoomProxyError> {
func clearDraft(threadRootEventID: String?) async -> Result<Void, RoomProxyError> {
do {
try await room.clearComposerDraft()
try await room.clearComposerDraft(threadRoot: threadRootEventID)
return .success(())
} catch {
MXLog.error("Failed clearing draft with error: \(error)")
@@ -187,9 +187,9 @@ protocol JoinedRoomProxyProtocol: RoomProxyProtocol {
// MARK: - Drafts
func saveDraft(_ draft: ComposerDraft) async -> Result<Void, RoomProxyError>
func loadDraft() async -> Result<ComposerDraft?, RoomProxyError>
func clearDraft() async -> Result<Void, RoomProxyError>
func saveDraft(_ draft: ComposerDraft, threadRootEventID: String?) async -> Result<Void, RoomProxyError>
func loadDraft(threadRootEventID: String?) async -> Result<ComposerDraft?, RoomProxyError>
func clearDraft(threadRootEventID: String?) async -> Result<Void, RoomProxyError>
}
extension JoinedRoomProxyProtocol {