compose: Minor improvements for download/install
Make purchase action noncancellable to allow it to happen even if user navigates away from the screen after requesting it. Also, don't allow expanding at all if no files are available as both actions at the moment requires files to be available. Signed-off-by: Aayush Gupta <aayushgupta219@gmail.com>
This commit is contained in:
@@ -137,7 +137,8 @@ fun DownloadComposable(
|
||||
trailingButton = {
|
||||
SplitButtonDefaults.TrailingButton(
|
||||
checked = isExpanded,
|
||||
onCheckedChange = { isExpanded = it }
|
||||
onCheckedChange = { isExpanded = it },
|
||||
enabled = download.canInstall(context)
|
||||
) {
|
||||
Icon(
|
||||
painter = when {
|
||||
|
||||
@@ -40,6 +40,7 @@ import com.aurora.store.util.Preferences.PREFERENCE_UPDATES_EXTENDED
|
||||
import dagger.hilt.android.lifecycle.HiltViewModel
|
||||
import dagger.hilt.android.qualifiers.ApplicationContext
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.NonCancellable
|
||||
import kotlinx.coroutines.flow.MutableSharedFlow
|
||||
import kotlinx.coroutines.flow.MutableStateFlow
|
||||
import kotlinx.coroutines.flow.SharingStarted
|
||||
@@ -219,7 +220,7 @@ class AppDetailsViewModel @Inject constructor(
|
||||
}
|
||||
|
||||
fun purchase(app: App) {
|
||||
viewModelScope.launch(Dispatchers.IO) {
|
||||
viewModelScope.launch(NonCancellable + Dispatchers.IO) {
|
||||
try {
|
||||
_state.value = AppState.Downloading(0F, 0 ,0)
|
||||
val files = purchaseHelper.purchase(app.packageName, app.versionCode, app.offerType)
|
||||
|
||||
Reference in New Issue
Block a user