Skip to content

Commit

Permalink
version bump + attempt to fix possible crash
Browse files Browse the repository at this point in the history
  • Loading branch information
patrickunterwegs committed May 29, 2024
1 parent bd4abc7 commit b9f5fda
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 16 deletions.
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ android {
buildConfigField "long", "buildTime", System.currentTimeMillis() + "L"
minSdkVersion 21
targetSdkVersion 34
versionCode 207090004
versionName "2.07.09-alpha04" // keep -release as a suffix also for release, build flavor adds the suffix e.g. .gplay (e.g. 1.00.00-rc0.gplay)
versionCode 207090005
versionName "2.07.09-alpha05" // keep -release as a suffix also for release, build flavor adds the suffix e.g. .gplay (e.g. 1.00.00-rc0.gplay)
buildConfigField "String", "versionCodename", "\"Love always wins ❤️💪\""
multiDexEnabled true
vectorDrawables.useSupportLibrary = true
Expand Down
39 changes: 25 additions & 14 deletions app/src/main/java/at/techbee/jtx/ui/detail/DetailViewModel.kt
Original file line number Diff line number Diff line change
Expand Up @@ -129,17 +129,17 @@ class DetailViewModel(application: Application) : AndroidViewModel(application)
originalEntry = databaseDao.getSync(icalObjectId)
mutableICalObject = originalEntry?.property
mutableCategories.clear()
mutableCategories.addAll(originalEntry?.categories ?: emptyList())
mutableCategories.addAll(databaseDao.getCategoriesSync(icalObjectId))
mutableResources.clear()
mutableResources.addAll(originalEntry?.resources ?: emptyList())
mutableResources.addAll(databaseDao.getResourcesSync(icalObjectId))
mutableAttendees.clear()
mutableAttendees.addAll(originalEntry?.attendees ?: emptyList())
mutableAttendees.addAll(databaseDao.getAttendeesSync(icalObjectId))
mutableComments.clear()
mutableComments.addAll(originalEntry?.comments ?: emptyList())
mutableComments.addAll(databaseDao.getCommentsSync(icalObjectId))
mutableAttachments.clear()
mutableAttachments.addAll(originalEntry?.attachments ?: emptyList())
mutableAttachments.addAll(databaseDao.getAttachmentsSync(icalObjectId))
mutableAlarms.clear()
mutableAlarms.addAll(originalEntry?.alarms ?: emptyList())
mutableAlarms.addAll(databaseDao.getAlarmsSync(icalObjectId))
}

//icalEntity = databaseDao.get(icalObjectId)
Expand Down Expand Up @@ -324,6 +324,16 @@ class DetailViewModel(application: Application) : AndroidViewModel(application)
withContext(Dispatchers.Main) { changeState.value = DetailChangeState.CHANGESAVING }

mutableICalObject?.let {
// make sure the eTag, flags, scheduleTag and fileName gets updated in the background if the sync is triggered, so that another sync won't overwrite the changes!
icalObject.value?.eTag.let { currentETag -> it.eTag = currentETag }
icalObject.value?.flags.let { currentFlags -> it.flags = currentFlags }
icalObject.value?.scheduleTag.let { currentScheduleTag ->
it.scheduleTag = currentScheduleTag
}
icalObject.value?.fileName.let { currentFileName ->
it.fileName = currentFileName
}

saveSuspend()
val newId = databaseDao.moveToCollection(it.id, newCollectionId)
if(newId == null) {
Expand Down Expand Up @@ -397,14 +407,6 @@ class DetailViewModel(application: Application) : AndroidViewModel(application)


fun saveEntry() {
viewModelScope.launch(Dispatchers.IO) {
withContext (Dispatchers.Main) { changeState.value = DetailChangeState.CHANGESAVING }
saveSuspend()
withContext (Dispatchers.Main) { changeState.value = DetailChangeState.CHANGESAVED }
}
}

private suspend fun saveSuspend() {
mutableICalObject?.let {
// make sure the eTag, flags, scheduleTag and fileName gets updated in the background if the sync is triggered, so that another sync won't overwrite the changes!
icalObject.value?.eTag.let { currentETag -> it.eTag = currentETag }
Expand All @@ -415,7 +417,16 @@ class DetailViewModel(application: Application) : AndroidViewModel(application)
icalObject.value?.fileName.let { currentFileName ->
it.fileName = currentFileName
}
}
viewModelScope.launch(Dispatchers.IO) {
withContext (Dispatchers.Main) { changeState.value = DetailChangeState.CHANGESAVING }
saveSuspend()
withContext (Dispatchers.Main) { changeState.value = DetailChangeState.CHANGESAVED }
}
}

private suspend fun saveSuspend() {
mutableICalObject?.let {
databaseDao.saveAll(
it,
mutableCategories,
Expand Down

0 comments on commit b9f5fda

Please sign in to comment.