mirror of
https://github.com/SchildiChat/SchildiChat-android.git
synced 2024-11-25 10:55:55 +03:00
Cleanup and fix a bug
This commit is contained in:
parent
f3e52b96c0
commit
ecc463e920
2 changed files with 17 additions and 19 deletions
|
@ -29,8 +29,9 @@ internal interface SendTypingTask : Task<SendTypingTask.Params, Unit> {
|
|||
data class Params(
|
||||
val roomId: String,
|
||||
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 {
|
||||
|
||||
override suspend fun execute(params: SendTypingTask.Params) {
|
||||
if (params.delay != null) {
|
||||
delay(params.delay)
|
||||
}
|
||||
|
||||
val body = if (params.isTyping) {
|
||||
TypingBody(true, params.typingTimeoutMillis)
|
||||
} else {
|
||||
TypingBody(false, null)
|
||||
}
|
||||
delay(params.delay ?: -1)
|
||||
|
||||
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()) {
|
||||
null
|
||||
} else {
|
||||
// TODO Check how costly it is to create a Room here
|
||||
val typingRoomMembers = typingHelper.toTypingRoomMembers(roomSummary.typingRoomMemberIds, session.getRoom(roomSummary.roomId))
|
||||
typingHelper.toTypingMessage(typingRoomMembers)
|
||||
}
|
||||
val typingString = typingHelper.excludeCurrentUser(roomSummary.typingRoomMemberIds)
|
||||
.takeIf { it.isNotEmpty() }
|
||||
?.let { typingMembers ->
|
||||
// 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 room = session.getRoom(roomSummary.roomId)
|
||||
val typingRoomMembers = typingHelper.toTypingRoomMembers(typingMembers, room)
|
||||
typingHelper.toTypingMessage(typingRoomMembers)
|
||||
}
|
||||
|
||||
return RoomSummaryItem_()
|
||||
.id(roomSummary.roomId)
|
||||
|
|
Loading…
Reference in a new issue