Merge pull request #5484 from vector-im/feature/aris/fix_realm_crash_1_4_4

Fix realm crash on v1.4.4
This commit is contained in:
Adam Brown 2022-03-09 18:55:12 +00:00 committed by GitHub
commit 9e8067dd19
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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
frozenSendingTimelineEvents?.realm?.close() if (frozenSendingTimelineEvents?.isValid == true) {
frozenSendingTimelineEvents?.realm?.close()
}
frozenSendingTimelineEvents = sendingEvents?.freeze() frozenSendingTimelineEvents = sendingEvents?.freeze()
} }
@ -74,13 +76,15 @@ internal class RealmSendingEventsDataSource(
val builtSendingEvents = mutableListOf<TimelineEvent>() val builtSendingEvents = mutableListOf<TimelineEvent>()
uiEchoManager.getInMemorySendingEvents() uiEchoManager.getInMemorySendingEvents()
.addWithUiEcho(builtSendingEvents) .addWithUiEcho(builtSendingEvents)
frozenSendingTimelineEvents if (frozenSendingTimelineEvents?.isValid == true) {
?.filter { timelineEvent -> frozenSendingTimelineEvents
builtSendingEvents.none { it.eventId == timelineEvent.eventId } ?.filter { timelineEvent ->
} builtSendingEvents.none { it.eventId == timelineEvent.eventId }
?.map { }
timelineEventMapper.map(it) ?.map {
}?.addWithUiEcho(builtSendingEvents) timelineEventMapper.map(it)
}?.addWithUiEcho(builtSendingEvents)
}
return builtSendingEvents return builtSendingEvents
} }