Realm: fix remaining frozen result

This commit is contained in:
ganfra 2022-02-23 18:02:02 +01:00
parent beeee7c84b
commit f7c79a6de2

View file

@ -46,7 +46,7 @@ internal class RealmSendingEventsDataSource(
private val sendingTimelineEventsListener = RealmChangeListener<RealmList<TimelineEventEntity>> { events ->
uiEchoManager.onSentEventsInDatabase(events.map { it.eventId })
frozenSendingTimelineEvents = sendingTimelineEvents?.freeze()
updateFrozenResults(events)
onEventsUpdated(false)
}
@ -59,10 +59,17 @@ internal class RealmSendingEventsDataSource(
override fun stop() {
sendingTimelineEvents?.removeChangeListener(sendingTimelineEventsListener)
updateFrozenResults(null)
sendingTimelineEvents = null
roomEntity = null
}
private fun updateFrozenResults(sendingEvents: RealmList<TimelineEventEntity>?) {
// Makes sure to close the previous frozen realm
frozenSendingTimelineEvents?.realm?.close()
frozenSendingTimelineEvents = sendingEvents?.freeze()
}
override fun buildSendingEvents(): List<TimelineEvent> {
val builtSendingEvents = mutableListOf<TimelineEvent>()
uiEchoManager.getInMemorySendingEvents()