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 31, 2024
1 parent f9b3df7 commit 1aef1e2
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 3 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
2 changes: 1 addition & 1 deletion app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
<string name="event_creation_error_end_date_before_start_date">The end date is before the start date</string>
<string name="event_creation_error_empty_title">The title is empty</string>
<string name="event_creation_error_max_participant">The maximum number of participants is too low</string>
<string name="event_creation_error_network_failure">Network problem while saving event. Please retry.</string>
<string name="event_creation_error_network_failure">Network problem while saving or deleting event. Please retry.</string>
<string name="search_menu_filters_epfl">EPFL</string>
<string name="search_menu_filters_section">Section</string>
<string name="search_menu_filters_class">Class</string>
Expand Down

0 comments on commit 1aef1e2

Please sign in to comment.