mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-03 06:55:59 +00:00
Store and restore drafts (#2898)
This commit is contained in:
@@ -565,6 +565,37 @@ class RoomProxy: RoomProxyProtocol {
|
||||
return .failure(.sdkError(error))
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - Drafts
|
||||
|
||||
func saveDraft(_ draft: ComposerDraft) async -> Result<Void, RoomProxyError> {
|
||||
do {
|
||||
try await room.saveComposerDraft(draft: draft)
|
||||
return .success(())
|
||||
} catch {
|
||||
MXLog.error("Failed saving draft with error: \(error)")
|
||||
return .failure(.sdkError(error))
|
||||
}
|
||||
}
|
||||
|
||||
func loadDraft() async -> Result<ComposerDraft?, RoomProxyError> {
|
||||
do {
|
||||
return try await .success(room.loadComposerDraft())
|
||||
} catch {
|
||||
MXLog.error("Failed restoring draft with error: \(error)")
|
||||
return .failure(.sdkError(error))
|
||||
}
|
||||
}
|
||||
|
||||
func clearDraft() async -> Result<Void, RoomProxyError> {
|
||||
do {
|
||||
try await room.clearComposerDraft()
|
||||
return .success(())
|
||||
} catch {
|
||||
MXLog.error("Failed clearing draft with error: \(error)")
|
||||
return .failure(.sdkError(error))
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - Private
|
||||
|
||||
|
||||
@@ -126,7 +126,6 @@ protocol RoomProxyProtocol {
|
||||
// MARK: - Element Call
|
||||
|
||||
func canUserJoinCall(userID: String) async -> Result<Bool, RoomProxyError>
|
||||
|
||||
func elementCallWidgetDriver() -> ElementCallWidgetDriverProtocol
|
||||
|
||||
func sendCallNotificationIfNeeeded() async -> Result<Void, RoomProxyError>
|
||||
@@ -134,8 +133,13 @@ protocol RoomProxyProtocol {
|
||||
// MARK: - Permalinks
|
||||
|
||||
func matrixToPermalink() async -> Result<URL, RoomProxyError>
|
||||
|
||||
func matrixToEventPermalink(_ eventID: String) async -> Result<URL, RoomProxyError>
|
||||
|
||||
// MARK: - Drafts
|
||||
|
||||
func saveDraft(_ draft: ComposerDraft) async -> Result<Void, RoomProxyError>
|
||||
func loadDraft() async -> Result<ComposerDraft?, RoomProxyError>
|
||||
func clearDraft() async -> Result<Void, RoomProxyError>
|
||||
}
|
||||
|
||||
extension RoomProxyProtocol {
|
||||
|
||||
Reference in New Issue
Block a user