Add isValid check to RealmChangeListener to prevent crashes on deleted objects

This commit is contained in:
ariskotsomitopoulos 2022-04-05 20:36:33 +03:00
parent 59d87df0ca
commit 37dc77cc3e
2 changed files with 5 additions and 4 deletions

View file

@ -45,9 +45,11 @@ internal class RealmSendingEventsDataSource(
private var frozenSendingTimelineEvents: RealmList<TimelineEventEntity>? = null
private val sendingTimelineEventsListener = RealmChangeListener<RealmList<TimelineEventEntity>> { events ->
uiEchoManager.onSentEventsInDatabase(events.map { it.eventId })
updateFrozenResults(events)
onEventsUpdated(false)
if (events.isValid) {
uiEchoManager.onSentEventsInDatabase(events.map { it.eventId })
updateFrozenResults(events)
onEventsUpdated(false)
}
}
override fun start() {

View file

@ -2393,7 +2393,6 @@ class TimelineFragment @Inject constructor(
.setCancelable(true)
.setNegativeButton(R.string.action_not_now) { _, _ -> }
.setPositiveButton(R.string.action_try_it_out) { _, _ ->
timelineViewModel.onCleared() // We should first clear our viewModel
threadsManager.enableThreadsAndRestart(it)
}
.show()