Skip to content

Commit

Permalink
fix: always use default patch selection if customization is disabled
Browse files Browse the repository at this point in the history
  • Loading branch information
Axelen123 committed Jul 20, 2024
1 parent de6fddf commit 2eca45d
Showing 1 changed file with 5 additions and 10 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package app.revanced.manager.ui.viewmodel

import android.app.Application
import android.content.pm.PackageInfo
import android.os.Parcelable
import androidx.compose.runtime.MutableState
Expand Down Expand Up @@ -38,7 +37,6 @@ class SelectedAppInfoViewModel(input: Params) : ViewModel(), KoinComponent {
private val optionsRepository: PatchOptionsRepository = get()
private val pm: PM = get()
private val savedStateHandle: SavedStateHandle = get()
private val app: Application = get()
val prefs: PreferencesManager = get()

private val persistConfiguration = input.patches == null
Expand Down Expand Up @@ -82,20 +80,17 @@ class SelectedAppInfoViewModel(input: Params) : ViewModel(), KoinComponent {
private set

private var selectionState by savedStateHandle.saveable {
if (input.patches != null) {
if (input.patches != null)
return@saveable mutableStateOf(SelectionState.Customized(input.patches))
}

val selection: MutableState<SelectionState> = mutableStateOf(SelectionState.Default)

// Get previous selection (if present).
// Try to get the previous selection if customization is enabled.
viewModelScope.launch {
val previous = selectionRepository.getSelection(selectedApp.packageName)

if (previous.values.sumOf { it.size } == 0) {
return@launch
}
if (!prefs.disableSelectionWarning.get()) return@launch

val previous = selectionRepository.getSelection(selectedApp.packageName)
if (previous.values.sumOf { it.size } == 0) return@launch
selection.value = SelectionState.Customized(previous)
}

Expand Down

0 comments on commit 2eca45d

Please sign in to comment.