mirror of
https://github.com/Novaloop-AG/element-x-android.git
synced 2026-11-02 21:32:34 +00:00
read : use the new apis
This commit is contained in:
+7
-5
@@ -153,15 +153,17 @@ interface MatrixRoom : Closeable {
|
||||
suspend fun reportContent(eventId: EventId, reason: String, blockUserId: UserId?): Result<Unit>
|
||||
|
||||
/**
|
||||
* Reverts a previously set unread flag, and eventually send a Read Receipt.
|
||||
* @param receiptType The type of receipt to send. If null, no Read Receipt will be sent.
|
||||
* Mark the room as read by trying to attach an unthreaded read receipt to the latest room event.
|
||||
* @param receiptType The type of receipt to send.
|
||||
*/
|
||||
suspend fun markAsRead(receiptType: ReceiptType?): Result<Unit>
|
||||
suspend fun markAsRead(receiptType: ReceiptType): Result<Unit>
|
||||
|
||||
/**
|
||||
* Sets a flag on the room to indicate that the user has explicitly marked it as unread.
|
||||
* Sets a flag on the room to indicate that the user has explicitly marked it as unread, or reverts the flag.
|
||||
* @param isUnread true to mark the room as unread, false to remove the flag.
|
||||
*
|
||||
*/
|
||||
suspend fun markAsUnread(): Result<Unit>
|
||||
suspend fun setUnreadFlag(isUnread: Boolean): Result<Unit>
|
||||
|
||||
/**
|
||||
* Share a location message in the room.
|
||||
|
||||
+4
-8
@@ -442,19 +442,15 @@ class RustMatrixRoom(
|
||||
}
|
||||
}
|
||||
|
||||
override suspend fun markAsRead(receiptType: ReceiptType?): Result<Unit> = withContext(roomDispatcher) {
|
||||
override suspend fun markAsRead(receiptType: ReceiptType): Result<Unit> = withContext(roomDispatcher) {
|
||||
runCatching {
|
||||
if (receiptType != null) {
|
||||
innerRoom.markAsReadAndSendReadReceipt(receiptType.toRustReceiptType())
|
||||
} else {
|
||||
innerRoom.markAsRead()
|
||||
}
|
||||
innerRoom.markAsRead(receiptType.toRustReceiptType())
|
||||
}
|
||||
}
|
||||
|
||||
override suspend fun markAsUnread(): Result<Unit> = withContext(roomDispatcher) {
|
||||
override suspend fun setUnreadFlag(isUnread: Boolean): Result<Unit> = withContext(roomDispatcher) {
|
||||
runCatching {
|
||||
innerRoom.markAsUnread()
|
||||
innerRoom.setUnreadFlag(isUnread)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+6
-5
@@ -378,17 +378,18 @@ class FakeMatrixRoom(
|
||||
return reportContentResult
|
||||
}
|
||||
|
||||
val markAsReadCalls = mutableListOf<ReceiptType?>()
|
||||
override suspend fun markAsRead(receiptType: ReceiptType?): Result<Unit> {
|
||||
val markAsReadCalls = mutableListOf<ReceiptType>()
|
||||
|
||||
override suspend fun markAsRead(receiptType: ReceiptType): Result<Unit> {
|
||||
markAsReadCalls.add(receiptType)
|
||||
return Result.success(Unit)
|
||||
}
|
||||
|
||||
var markAsUnreadReadCallCount = 0
|
||||
var setUnreadFlagCalls = mutableListOf<Boolean>()
|
||||
private set
|
||||
|
||||
override suspend fun markAsUnread(): Result<Unit> {
|
||||
markAsUnreadReadCallCount++
|
||||
override suspend fun setUnreadFlag(isUnread: Boolean): Result<Unit> {
|
||||
setUnreadFlagCalls.add(isUnread)
|
||||
return Result.success(Unit)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user