Fix realm crash on v1.4.4

This commit is contained in:
ariskotsomitopoulos 2022-03-09 20:03:42 +02:00
parent 8c36bdb0e9
commit 92c1bc944d
1 changed files with 12 additions and 8 deletions

View File

@ -66,7 +66,9 @@ internal class RealmSendingEventsDataSource(
private fun updateFrozenResults(sendingEvents: RealmList<TimelineEventEntity>?) { private fun updateFrozenResults(sendingEvents: RealmList<TimelineEventEntity>?) {
// Makes sure to close the previous frozen realm // Makes sure to close the previous frozen realm
if (frozenSendingTimelineEvents?.isValid == true) {
frozenSendingTimelineEvents?.realm?.close() frozenSendingTimelineEvents?.realm?.close()
}
frozenSendingTimelineEvents = sendingEvents?.freeze() frozenSendingTimelineEvents = sendingEvents?.freeze()
} }
@ -74,6 +76,7 @@ internal class RealmSendingEventsDataSource(
val builtSendingEvents = mutableListOf<TimelineEvent>() val builtSendingEvents = mutableListOf<TimelineEvent>()
uiEchoManager.getInMemorySendingEvents() uiEchoManager.getInMemorySendingEvents()
.addWithUiEcho(builtSendingEvents) .addWithUiEcho(builtSendingEvents)
if (frozenSendingTimelineEvents?.isValid == true) {
frozenSendingTimelineEvents frozenSendingTimelineEvents
?.filter { timelineEvent -> ?.filter { timelineEvent ->
builtSendingEvents.none { it.eventId == timelineEvent.eventId } builtSendingEvents.none { it.eventId == timelineEvent.eventId }
@ -81,6 +84,7 @@ internal class RealmSendingEventsDataSource(
?.map { ?.map {
timelineEventMapper.map(it) timelineEventMapper.map(it)
}?.addWithUiEcho(builtSendingEvents) }?.addWithUiEcho(builtSendingEvents)
}
return builtSendingEvents return builtSendingEvents
} }