mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-04 01:20:12 +00:00
Bump the RustSDK, adopt new marking/flagging rooms as (un)read API and fix sending read receipts when entering rooms or making the app active again
This commit is contained in:
committed by
Stefan Ceriu
parent
e11450e61e
commit
5cb5862e5e
@@ -368,28 +368,33 @@ class RoomProxy: RoomProxyProtocol {
|
||||
}
|
||||
}
|
||||
|
||||
func markAsUnread() async -> Result<Void, RoomProxyError> {
|
||||
MXLog.info("Marking room \(id) as unread")
|
||||
func flagAsUnread() async -> Result<Void, RoomProxyError> {
|
||||
MXLog.info("Flagging room \(id) as unread")
|
||||
|
||||
do {
|
||||
try await room.markAsUnread()
|
||||
try await room.setUnreadFlag(newValue: true)
|
||||
return .success(())
|
||||
} catch {
|
||||
MXLog.error("Failed marking room \(id) as unread with error: \(error)")
|
||||
return .failure(.failedMarkingAsUnread)
|
||||
return .failure(.failedFlaggingAsUnread)
|
||||
}
|
||||
}
|
||||
|
||||
func markAsRead(sendReadReceipts: Bool, receiptType: ReceiptType) async -> Result<Void, RoomProxyError> {
|
||||
MXLog.info("Marking room \(id) as read, sending read receipts: \(sendReadReceipts)")
|
||||
func flagAsRead() async -> Result<Void, RoomProxyError> {
|
||||
MXLog.info("Flagging room \(id) as read")
|
||||
|
||||
do {
|
||||
if sendReadReceipts {
|
||||
try await room.markAsReadAndSendReadReceipt(receiptType: receiptType)
|
||||
} else {
|
||||
try await room.markAsRead()
|
||||
}
|
||||
|
||||
try await room.setUnreadFlag(newValue: false)
|
||||
return .success(())
|
||||
} catch {
|
||||
MXLog.error("Failed marking room \(id) as read with error: \(error)")
|
||||
return .failure(.failedFlaggingAsRead)
|
||||
}
|
||||
}
|
||||
|
||||
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)")
|
||||
|
||||
@@ -31,8 +31,9 @@ enum RoomProxyError: Error, Equatable {
|
||||
case failedRemovingAvatar
|
||||
case failedUploadingAvatar
|
||||
case failedCheckingPermission
|
||||
case failedFlaggingAsUnread
|
||||
case failedFlaggingAsRead
|
||||
case failedMarkingAsRead
|
||||
case failedMarkingAsUnread
|
||||
case failedSendingTypingNotice
|
||||
}
|
||||
|
||||
@@ -108,9 +109,11 @@ protocol RoomProxyProtocol {
|
||||
|
||||
func canUserTriggerRoomNotification(userID: String) async -> Result<Bool, RoomProxyError>
|
||||
|
||||
func markAsUnread() async -> Result<Void, RoomProxyError>
|
||||
func flagAsUnread() async -> Result<Void, RoomProxyError>
|
||||
|
||||
func markAsRead(sendReadReceipts: Bool, receiptType: ReceiptType) async -> Result<Void, RoomProxyError>
|
||||
func flagAsRead() async -> Result<Void, RoomProxyError>
|
||||
|
||||
func markAsRead(receiptType: ReceiptType) async -> Result<Void, RoomProxyError>
|
||||
|
||||
/// https://spec.matrix.org/v1.9/client-server-api/#typing-notifications
|
||||
@discardableResult func sendTypingNotification(isTyping: Bool) async -> Result<Void, RoomProxyError>
|
||||
|
||||
+3
-8
@@ -55,14 +55,9 @@ class MockRoomTimelineController: RoomTimelineControllerProtocol {
|
||||
return .success(())
|
||||
}
|
||||
|
||||
func sendReadReceipt(for itemID: TimelineItemIdentifier) async -> Result<Void, RoomTimelineControllerError> {
|
||||
guard let roomProxy, let eventID = itemID.eventID else { return .failure(.generic) }
|
||||
switch await roomProxy.timeline.sendReadReceipt(for: eventID, type: .read) {
|
||||
case .success:
|
||||
return .success(())
|
||||
case .failure:
|
||||
return .failure(.generic)
|
||||
}
|
||||
func sendReadReceipt(for itemID: TimelineItemIdentifier) async {
|
||||
guard let roomProxy, let eventID = itemID.eventID else { return }
|
||||
_ = await roomProxy.timeline.sendReadReceipt(for: eventID, type: .read)
|
||||
}
|
||||
|
||||
func processItemAppearance(_ itemID: TimelineItemIdentifier) async { }
|
||||
|
||||
+12
-10
@@ -16,6 +16,7 @@
|
||||
|
||||
import Combine
|
||||
import Foundation
|
||||
import MatrixRustSDK
|
||||
import UIKit
|
||||
|
||||
class RoomTimelineController: RoomTimelineControllerProtocol {
|
||||
@@ -91,17 +92,18 @@ class RoomTimelineController: RoomTimelineControllerProtocol {
|
||||
}
|
||||
}
|
||||
|
||||
func sendReadReceipt(for itemID: TimelineItemIdentifier) async -> Result<Void, RoomTimelineControllerError> {
|
||||
guard let eventID = itemID.eventID else {
|
||||
return .failure(.generic)
|
||||
}
|
||||
func sendReadReceipt(for itemID: TimelineItemIdentifier) async {
|
||||
let receiptType: MatrixRustSDK.ReceiptType = appSettings.sharePresence ? .read : .readPrivate
|
||||
|
||||
switch await roomProxy.timeline.sendReadReceipt(for: eventID,
|
||||
type: appSettings.sharePresence ? .read : .readPrivate) {
|
||||
case .success:
|
||||
return .success(())
|
||||
case .failure:
|
||||
return .failure(.generic)
|
||||
// Mark the whole room as read if it's the last timeline item
|
||||
if timelineItems.last?.id == itemID {
|
||||
_ = await roomProxy.markAsRead(receiptType: receiptType)
|
||||
} else {
|
||||
guard let eventID = itemID.eventID else {
|
||||
return
|
||||
}
|
||||
|
||||
_ = await roomProxy.timeline.sendReadReceipt(for: eventID, type: receiptType)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -49,7 +49,7 @@ protocol RoomTimelineControllerProtocol {
|
||||
|
||||
func paginateBackwards(requestSize: UInt, untilNumberOfItems: UInt) async -> Result<Void, RoomTimelineControllerError>
|
||||
|
||||
func sendReadReceipt(for itemID: TimelineItemIdentifier) async -> Result<Void, RoomTimelineControllerError>
|
||||
func sendReadReceipt(for itemID: TimelineItemIdentifier) async
|
||||
|
||||
func sendMessage(_ message: String,
|
||||
html: String?,
|
||||
|
||||
@@ -454,7 +454,7 @@ final class TimelineProxy: TimelineProxyProtocol {
|
||||
}
|
||||
|
||||
func sendReadReceipt(for eventID: String, type: ReceiptType) async -> Result<Void, TimelineProxyError> {
|
||||
MXLog.info("Sending read receipt for eventID: \(eventID)")
|
||||
MXLog.verbose("Sending read receipt for eventID: \(eventID)")
|
||||
|
||||
sendMessageBackgroundTask = await backgroundTaskService.startBackgroundTask(withName: backgroundTaskName, isReusable: true)
|
||||
defer {
|
||||
|
||||
Reference in New Issue
Block a user