Extract condition to reduce code complexity

This commit is contained in:
Florian Renaud 2022-08-17 16:36:52 +02:00
parent cbf9dbf290
commit 128ff0d6ec

View File

@ -46,8 +46,7 @@ internal class DefaultSendEventTask @Inject constructor(
override suspend fun execute(params: SendEventTask.Params): String {
try {
if (RoomLocalEcho.isLocalEchoId(params.event.roomId.orEmpty())) {
// Room is local, so create a real one and send the event to this new room
if (params.event.isLocalRoomEvent) {
return createRoomAndSendEvent(params)
}
@ -105,4 +104,7 @@ internal class DefaultSendEventTask @Inject constructor(
}
return params.event
}
private val Event.isLocalRoomEvent
get() = RoomLocalEcho.isLocalEchoId(roomId.orEmpty())
}