🛠️ Fix crash when deleting color preset
Fixed crash when deleting color preset (IndexOutOfBounds)
This commit is contained in:
parent
a09e43583b
commit
d23a2ed11f
1 changed files with 5 additions and 1 deletions
|
|
@ -280,6 +280,7 @@ class SettingsViewModel @Inject constructor(
|
|||
viewModelScope.launch {
|
||||
cancelColorPresetJobs()
|
||||
deleteColorPresetJob = launch {
|
||||
if (_state.value.colorPresets.size == 1) return@launch
|
||||
val colorPreset = getColorPresetById(event.id) ?: return@launch
|
||||
|
||||
yield()
|
||||
|
|
@ -298,7 +299,10 @@ class SettingsViewModel @Inject constructor(
|
|||
yield()
|
||||
|
||||
deleteColorPreset.execute(colorPreset)
|
||||
onSelectColorPreset(getColorPresets.execute()[nextPosition])
|
||||
val nextColorPreset = getColorPresets.execute().getOrNull(nextPosition)
|
||||
?: return@launch
|
||||
|
||||
onSelectColorPreset(nextColorPreset)
|
||||
val colorPresets = getColorPresets.execute()
|
||||
|
||||
_state.update {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue