Skip to content

Commit

Permalink
📦 NEW: branch event deletion button on repository
Browse files Browse the repository at this point in the history
Signed-off-by: Jonas Sulzer <jonas@violoncello.ch>
  • Loading branch information
violoncelloCH committed May 30, 2024
1 parent ffa7b6d commit 2fa2397
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,7 @@ fun EventScreen(
) {
if (canDelete) {
DeleteEventButton(enabled = isOnline) {
// TODO: delete the event in the repository
onEventDeleted()
eventViewModel.deleteEvent(onEventDeleted)
}
}
OutlinedButton(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,18 @@ constructor(
}
}

// delete the current event in the repository
fun deleteEvent(onEventDeleted: () -> Unit) {
viewModelScope.launch {
try {
repository.deleteEvent(event.value)
onEventDeleted()
} catch (e: RepositoryStoreWhileNoInternetException) {
_status.value = EventStatus.Error(R.string.event_creation_error_network_failure)
}
}
}

/** change event status from error to modified */
fun dismissError() {
if (_status.value is EventStatus.Error) {
Expand Down

0 comments on commit 2fa2397

Please sign in to comment.