mirror of
https://github.com/ouchadam/small-talk.git
synced 2025-02-03 21:07:34 +01:00
lifting hidden/private read receipt option to the view model
This commit is contained in:
parent
43e53261b6
commit
0e4f6d6ac2
@ -101,7 +101,7 @@ internal class MessengerViewModel(
|
||||
private fun CoroutineScope.updateRoomReadStateAsync(latestReadEvent: EventId, state: MessengerState): Deferred<Unit> {
|
||||
return async {
|
||||
runCatching {
|
||||
roomService.markFullyRead(state.roomState.roomOverview.roomId, latestReadEvent)
|
||||
roomService.markFullyRead(state.roomState.roomOverview.roomId, latestReadEvent, isPrivate = true)
|
||||
roomStore.markRead(state.roomState.roomOverview.roomId)
|
||||
}
|
||||
}
|
||||
|
@ -69,7 +69,7 @@ class MessengerViewModelTest {
|
||||
@Test
|
||||
fun `given timeline emits state, when starting, then updates state and marks room and events as read`() = runViewModelTest {
|
||||
fakeRoomStore.expectUnit(times = 2) { it.markRead(A_ROOM_ID) }
|
||||
fakeRoomService.expectUnit { it.markFullyRead(A_ROOM_ID, AN_EVENT_ID) }
|
||||
fakeRoomService.expectUnit { it.markFullyRead(A_ROOM_ID, AN_EVENT_ID, isPrivate = true) }
|
||||
val state = aMessengerStateWithEvent(AN_EVENT_ID, A_SELF_ID)
|
||||
fakeObserveTimelineUseCase.given(A_ROOM_ID, A_SELF_ID).returns(flowOf(state))
|
||||
|
||||
|
@ -15,7 +15,7 @@ private val SERVICE_KEY = RoomService::class
|
||||
interface RoomService : MatrixService {
|
||||
|
||||
suspend fun joinedMembers(roomId: RoomId): List<JoinedMember>
|
||||
suspend fun markFullyRead(roomId: RoomId, eventId: EventId)
|
||||
suspend fun markFullyRead(roomId: RoomId, eventId: EventId, isPrivate: Boolean)
|
||||
|
||||
suspend fun findMember(roomId: RoomId, userId: UserId): RoomMember?
|
||||
suspend fun findMembers(roomId: RoomId, userIds: List<UserId>): List<RoomMember>
|
||||
|
@ -30,9 +30,9 @@ class DefaultRoomService(
|
||||
}
|
||||
}
|
||||
|
||||
override suspend fun markFullyRead(roomId: RoomId, eventId: EventId) {
|
||||
override suspend fun markFullyRead(roomId: RoomId, eventId: EventId, isPrivate: Boolean) {
|
||||
logger.matrixLog(ROOM, "marking room fully read ${roomId.value}")
|
||||
httpClient.execute(markFullyReadRequest(roomId, eventId))
|
||||
httpClient.execute(markFullyReadRequest(roomId, eventId, isPrivate))
|
||||
}
|
||||
|
||||
override suspend fun findMember(roomId: RoomId, userId: UserId): RoomMember? {
|
||||
@ -97,10 +97,10 @@ internal fun joinedMembersRequest(roomId: RoomId) = httpRequest<JoinedMembersRes
|
||||
method = MatrixHttpClient.Method.GET,
|
||||
)
|
||||
|
||||
internal fun markFullyReadRequest(roomId: RoomId, eventId: EventId) = httpRequest<Unit>(
|
||||
internal fun markFullyReadRequest(roomId: RoomId, eventId: EventId, isPrivate: Boolean) = httpRequest<Unit>(
|
||||
path = "_matrix/client/r0/rooms/${roomId.value}/read_markers",
|
||||
method = MatrixHttpClient.Method.POST,
|
||||
body = jsonBody(MarkFullyReadRequest(eventId, eventId, hidden = true))
|
||||
body = jsonBody(MarkFullyReadRequest(eventId, eventId, hidden = isPrivate))
|
||||
)
|
||||
|
||||
internal fun createRoomRequest(invites: List<UserId>, isDM: Boolean, visibility: RoomVisibility, name: String? = null) = httpRequest<ApiCreateRoomResponse>(
|
||||
|
Loading…
x
Reference in New Issue
Block a user