🛠️ 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 {
|
viewModelScope.launch {
|
||||||
cancelColorPresetJobs()
|
cancelColorPresetJobs()
|
||||||
deleteColorPresetJob = launch {
|
deleteColorPresetJob = launch {
|
||||||
|
if (_state.value.colorPresets.size == 1) return@launch
|
||||||
val colorPreset = getColorPresetById(event.id) ?: return@launch
|
val colorPreset = getColorPresetById(event.id) ?: return@launch
|
||||||
|
|
||||||
yield()
|
yield()
|
||||||
|
|
@ -298,7 +299,10 @@ class SettingsViewModel @Inject constructor(
|
||||||
yield()
|
yield()
|
||||||
|
|
||||||
deleteColorPreset.execute(colorPreset)
|
deleteColorPreset.execute(colorPreset)
|
||||||
onSelectColorPreset(getColorPresets.execute()[nextPosition])
|
val nextColorPreset = getColorPresets.execute().getOrNull(nextPosition)
|
||||||
|
?: return@launch
|
||||||
|
|
||||||
|
onSelectColorPreset(nextColorPreset)
|
||||||
val colorPresets = getColorPresets.execute()
|
val colorPresets = getColorPresets.execute()
|
||||||
|
|
||||||
_state.update {
|
_state.update {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue