Cleanup and fix a bug
This commit is contained in:
parent
f3e52b96c0
commit
ecc463e920
|
@ -29,8 +29,9 @@ internal interface SendTypingTask : Task<SendTypingTask.Params, Unit> {
|
||||||
data class Params(
|
data class Params(
|
||||||
val roomId: String,
|
val roomId: String,
|
||||||
val isTyping: Boolean,
|
val isTyping: Boolean,
|
||||||
val delay: Long? = null,
|
val typingTimeoutMillis: Int? = 30_000,
|
||||||
val typingTimeoutMillis: Int? = 30_000
|
// Optional delay before sending the request to the homeserver
|
||||||
|
val delay: Long? = null
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -41,18 +42,14 @@ internal class DefaultSendTypingTask @Inject constructor(
|
||||||
) : SendTypingTask {
|
) : SendTypingTask {
|
||||||
|
|
||||||
override suspend fun execute(params: SendTypingTask.Params) {
|
override suspend fun execute(params: SendTypingTask.Params) {
|
||||||
if (params.delay != null) {
|
delay(params.delay ?: -1)
|
||||||
delay(params.delay)
|
|
||||||
}
|
|
||||||
|
|
||||||
val body = if (params.isTyping) {
|
|
||||||
TypingBody(true, params.typingTimeoutMillis)
|
|
||||||
} else {
|
|
||||||
TypingBody(false, null)
|
|
||||||
}
|
|
||||||
|
|
||||||
executeRequest<Unit>(eventBus) {
|
executeRequest<Unit>(eventBus) {
|
||||||
apiCall = roomAPI.sendTypingState(params.roomId, userId, body)
|
apiCall = roomAPI.sendTypingState(
|
||||||
|
params.roomId,
|
||||||
|
userId,
|
||||||
|
TypingBody(params.isTyping, params.typingTimeoutMillis?.takeIf { params.isTyping })
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -126,13 +126,14 @@ class RoomSummaryItemFactory @Inject constructor(private val noticeEventFormatte
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
val typingString = if (typingHelper.excludeCurrentUser(roomSummary.typingRoomMemberIds).isEmpty()) {
|
val typingString = typingHelper.excludeCurrentUser(roomSummary.typingRoomMemberIds)
|
||||||
null
|
.takeIf { it.isNotEmpty() }
|
||||||
} else {
|
?.let { typingMembers ->
|
||||||
// TODO Check how costly it is to create a Room here
|
// It's not ideal to get a Room and to fetch data from DB here, but let's keep it like this for the moment
|
||||||
val typingRoomMembers = typingHelper.toTypingRoomMembers(roomSummary.typingRoomMemberIds, session.getRoom(roomSummary.roomId))
|
val room = session.getRoom(roomSummary.roomId)
|
||||||
typingHelper.toTypingMessage(typingRoomMembers)
|
val typingRoomMembers = typingHelper.toTypingRoomMembers(typingMembers, room)
|
||||||
}
|
typingHelper.toTypingMessage(typingRoomMembers)
|
||||||
|
}
|
||||||
|
|
||||||
return RoomSummaryItem_()
|
return RoomSummaryItem_()
|
||||||
.id(roomSummary.roomId)
|
.id(roomSummary.roomId)
|
||||||
|
|
Loading…
Reference in New Issue