Skip to content

Commit

Permalink
Attempt to resolve Possible crash "Reading a state that was created a…
Browse files Browse the repository at this point in the history
…fter the snapshot was taken or in a snapshot that has not yet been applied"

Closes #1633
  • Loading branch information
patrickunterwegs committed Nov 17, 2024
1 parent 406d068 commit 73085b5
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions app/src/main/java/at/techbee/jtx/ui/detail/DetailViewModel.kt
Original file line number Diff line number Diff line change
Expand Up @@ -128,20 +128,21 @@ class DetailViewModel(application: Application) : AndroidViewModel(application)
viewModelScope.launch {
withContext(Dispatchers.Main) { changeState.value = DetailChangeState.LOADING }

mutableCategories.clear()
mutableResources.clear()
mutableAttendees.clear()
mutableComments.clear()
mutableAttachments.clear()
mutableAlarms.clear()

withContext(Dispatchers.IO) {
originalEntry = databaseDao.getSync(icalObjectId)
mutableICalObject = originalEntry?.property
mutableCategories.clear()
mutableCategories.addAll(databaseDao.getCategoriesSync(icalObjectId))
mutableResources.clear()
mutableResources.addAll(databaseDao.getResourcesSync(icalObjectId))
mutableAttendees.clear()
mutableAttendees.addAll(databaseDao.getAttendeesSync(icalObjectId))
mutableComments.clear()
mutableComments.addAll(databaseDao.getCommentsSync(icalObjectId))
mutableAttachments.clear()
mutableAttachments.addAll(databaseDao.getAttachmentsSync(icalObjectId))
mutableAlarms.clear()
mutableAlarms.addAll(databaseDao.getAlarmsSync(icalObjectId))
}

Expand Down

0 comments on commit 73085b5

Please sign in to comment.