Code Review

This commit is contained in:
Valere
2019-05-10 12:14:40 +02:00
parent cfca4927e2
commit 6bf1deb99b
12 changed files with 102 additions and 146 deletions

View File

@ -23,7 +23,7 @@ import im.vector.matrix.android.api.session.room.timeline.TimelineService
import im.vector.matrix.android.internal.database.model.EventEntity
import im.vector.matrix.android.internal.database.query.where
import im.vector.matrix.android.internal.task.TaskExecutor
import im.vector.matrix.android.internal.util.fetchMappedCopied
import im.vector.matrix.android.internal.util.fetchCopyMap
internal class DefaultTimelineService(private val roomId: String,
private val monarchy: Monarchy,
@ -38,7 +38,7 @@ internal class DefaultTimelineService(private val roomId: String,
}
override fun getTimeLineEvent(eventId: String): TimelineEvent? {
return monarchy.fetchMappedCopied({
return monarchy.fetchCopyMap({
EventEntity.where(it, eventId = eventId).findFirst()
}, { entity, realm ->
timelineEventFactory.create(entity, realm)

View File

@ -42,7 +42,7 @@ fun <T : RealmModel> Monarchy.fetchCopied(query: (Realm) -> T?): T? {
return fetch(query, true)
}
fun <U, T : RealmModel> Monarchy.fetchMappedCopied(query: (Realm) -> T?, map: (T, realm: Realm) -> U): U? {
fun <U, T : RealmModel> Monarchy.fetchCopyMap(query: (Realm) -> T?, map: (T, realm: Realm) -> U): U? {
val ref = AtomicReference<U?>()
doWithRealm { realm ->
val result = query.invoke(realm)?.let {