mirror of
https://github.com/ReVanced/revanced-manager.git
synced 2026-01-11 13:46:17 +00:00
fix: Update selected patch count when SelectionState changes (#2896)
This commit is contained in:
@@ -25,6 +25,7 @@ import androidx.compose.material3.TextButton
|
|||||||
import androidx.compose.material3.TopAppBarDefaults
|
import androidx.compose.material3.TopAppBarDefaults
|
||||||
import androidx.compose.material3.rememberTopAppBarState
|
import androidx.compose.material3.rememberTopAppBarState
|
||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.Composable
|
||||||
|
import androidx.compose.runtime.derivedStateOf
|
||||||
import androidx.compose.runtime.getValue
|
import androidx.compose.runtime.getValue
|
||||||
import androidx.compose.runtime.remember
|
import androidx.compose.runtime.remember
|
||||||
import androidx.compose.runtime.rememberCoroutineScope
|
import androidx.compose.runtime.rememberCoroutineScope
|
||||||
@@ -76,12 +77,12 @@ fun SelectedAppInfoScreen(
|
|||||||
val bundles by vm.bundleInfoFlow.collectAsStateWithLifecycle(emptyList())
|
val bundles by vm.bundleInfoFlow.collectAsStateWithLifecycle(emptyList())
|
||||||
|
|
||||||
val allowIncompatiblePatches by vm.prefs.disablePatchVersionCompatCheck.getAsState()
|
val allowIncompatiblePatches by vm.prefs.disablePatchVersionCompatCheck.getAsState()
|
||||||
val patches = remember(bundles, allowIncompatiblePatches) {
|
val patches by remember {
|
||||||
vm.getPatches(bundles, allowIncompatiblePatches)
|
derivedStateOf {
|
||||||
}
|
vm.getPatches(bundles, allowIncompatiblePatches)
|
||||||
val selectedPatchCount = remember(patches) {
|
}
|
||||||
patches.values.sumOf { it.size }
|
|
||||||
}
|
}
|
||||||
|
val selectedPatchCount = patches.values.sumOf { it.size }
|
||||||
|
|
||||||
val launcher = rememberLauncherForActivityResult(
|
val launcher = rememberLauncherForActivityResult(
|
||||||
contract = ActivityResultContracts.StartActivityForResult(),
|
contract = ActivityResultContracts.StartActivityForResult(),
|
||||||
|
|||||||
@@ -8,7 +8,6 @@ import android.os.Parcelable
|
|||||||
import android.util.Log
|
import android.util.Log
|
||||||
import androidx.activity.result.ActivityResult
|
import androidx.activity.result.ActivityResult
|
||||||
import androidx.annotation.StringRes
|
import androidx.annotation.StringRes
|
||||||
import androidx.compose.runtime.MutableState
|
|
||||||
import androidx.compose.runtime.derivedStateOf
|
import androidx.compose.runtime.derivedStateOf
|
||||||
import androidx.compose.runtime.getValue
|
import androidx.compose.runtime.getValue
|
||||||
import androidx.compose.runtime.mutableStateOf
|
import androidx.compose.runtime.mutableStateOf
|
||||||
@@ -129,8 +128,6 @@ class SelectedAppInfoViewModel(
|
|||||||
}
|
}
|
||||||
|
|
||||||
var options: Options by savedStateHandle.saveable {
|
var options: Options by savedStateHandle.saveable {
|
||||||
val state = mutableStateOf<Options>(emptyMap())
|
|
||||||
|
|
||||||
viewModelScope.launch {
|
viewModelScope.launch {
|
||||||
if (!persistConfiguration) return@launch // TODO: save options for patched apps.
|
if (!persistConfiguration) return@launch // TODO: save options for patched apps.
|
||||||
val bundlePatches = bundleInfoFlow.first()
|
val bundlePatches = bundleInfoFlow.first()
|
||||||
@@ -141,7 +138,7 @@ class SelectedAppInfoViewModel(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
state
|
mutableStateOf(emptyMap())
|
||||||
}
|
}
|
||||||
private set
|
private set
|
||||||
|
|
||||||
@@ -149,8 +146,6 @@ class SelectedAppInfoViewModel(
|
|||||||
if (input.patches != null)
|
if (input.patches != null)
|
||||||
return@saveable mutableStateOf(SelectionState.Customized(input.patches))
|
return@saveable mutableStateOf(SelectionState.Customized(input.patches))
|
||||||
|
|
||||||
val selection: MutableState<SelectionState> = mutableStateOf(SelectionState.Default)
|
|
||||||
|
|
||||||
// Try to get the previous selection if customization is enabled.
|
// Try to get the previous selection if customization is enabled.
|
||||||
viewModelScope.launch {
|
viewModelScope.launch {
|
||||||
if (!prefs.disableSelectionWarning.get()) return@launch
|
if (!prefs.disableSelectionWarning.get()) return@launch
|
||||||
@@ -160,7 +155,7 @@ class SelectedAppInfoViewModel(
|
|||||||
selectionState = SelectionState.Customized(previous)
|
selectionState = SelectionState.Customized(previous)
|
||||||
}
|
}
|
||||||
|
|
||||||
selection
|
mutableStateOf(SelectionState.Default)
|
||||||
}
|
}
|
||||||
|
|
||||||
var showSourceSelector by mutableStateOf(false)
|
var showSourceSelector by mutableStateOf(false)
|
||||||
@@ -311,7 +306,7 @@ class SelectedAppInfoViewModel(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
enum class Error(@StringRes val resourceId: Int) {
|
enum class Error(@param:StringRes val resourceId: Int) {
|
||||||
NoPlugins(R.string.downloader_no_plugins_available)
|
NoPlugins(R.string.downloader_no_plugins_available)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user