mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-02 21:33:26 +00:00
Use the timeline when marking a room as read (#4319)
* Forward JoinedRoomProxy.markAsRead to the timeline The room version was building a fresh timeline even though we already had one. * Run swiftformat 0.57.0.
This commit is contained in:
@@ -402,14 +402,16 @@ class JoinedRoomProxy: JoinedRoomProxyProtocol {
|
||||
return .failure(.sdkError(error))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
func markAsRead(receiptType: ReceiptType) async -> Result<Void, RoomProxyError> {
|
||||
do {
|
||||
try await room.markAsRead(receiptType: receiptType)
|
||||
return .success(())
|
||||
} catch {
|
||||
MXLog.error("Failed marking room \(id) as read with error: \(error)")
|
||||
return .failure(.sdkError(error))
|
||||
// Defer to the timeline here as room.markAsRead will build a fresh timeline.
|
||||
switch await timeline.markAsRead(receiptType: receiptType) {
|
||||
case .success:
|
||||
.success(())
|
||||
case .failure(.sdkError(let error)):
|
||||
.failure(.sdkError(error))
|
||||
case .failure(let error):
|
||||
.failure(.timelineError(error))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -17,6 +17,7 @@ enum RoomProxyError: Error {
|
||||
case eventNotFound
|
||||
case missingTransactionID
|
||||
case failedCreatingPinnedTimeline
|
||||
case timelineError(TimelineProxyError)
|
||||
}
|
||||
|
||||
/// An enum that describes the relationship between the current user and the room, and contains a reference to the specific implementation of the `RoomProxy`.
|
||||
|
||||
@@ -514,6 +514,19 @@ final class TimelineProxy: TimelineProxyProtocol {
|
||||
}
|
||||
}
|
||||
|
||||
func markAsRead(receiptType: ReceiptType) async -> Result<Void, TimelineProxyError> {
|
||||
MXLog.info("Marking as \(receiptType)")
|
||||
|
||||
do {
|
||||
try await timeline.markAsRead(receiptType: receiptType)
|
||||
MXLog.info("Finished marking as read")
|
||||
return .success(())
|
||||
} catch {
|
||||
MXLog.error("Failed marking as \(receiptType) with error: \(error)")
|
||||
return .failure(.sdkError(error))
|
||||
}
|
||||
}
|
||||
|
||||
func toggleReaction(_ reaction: String, to eventOrTransactionID: TimelineItemIdentifier.EventOrTransactionID) async -> Result<Void, TimelineProxyError> {
|
||||
MXLog.info("Toggling reaction \(reaction) for event: \(eventOrTransactionID)")
|
||||
|
||||
|
||||
@@ -119,6 +119,7 @@ protocol TimelineProxyProtocol {
|
||||
requestHandle: @MainActor (SendAttachmentJoinHandleProtocol) -> Void) async -> Result<Void, TimelineProxyError>
|
||||
|
||||
func sendReadReceipt(for eventID: String, type: ReceiptType) async -> Result<Void, TimelineProxyError>
|
||||
func markAsRead(receiptType: ReceiptType) async -> Result<Void, TimelineProxyError>
|
||||
|
||||
func sendMessageEventContent(_ messageContent: RoomMessageEventContentWithoutRelation) async -> Result<Void, TimelineProxyError>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user