compose: details: Also map requested version code to shared libraries

Forward port e766c8000b but for compose

Signed-off-by: Aayush Gupta <aayushgupta219@gmail.com>
This commit is contained in:
Aayush Gupta
2025-09-01 22:57:06 +08:00
parent 63b7bbb031
commit 0e4184f434
2 changed files with 12 additions and 6 deletions

View File

@@ -92,7 +92,15 @@ fun ManualDownloadScreen(
currentVersionCode = app!!.versionCode,
onNavigateUp = onNavigateUp,
onDownload = { versionCode ->
viewModel.purchase(app!!.copy(versionCode = versionCode))
val requestedApp = app!!.copy(
versionCode = versionCode,
dependencies = app!!.dependencies.copy(
dependentLibraries = app!!.dependencies.dependentLibraries.map { lib ->
lib.copy(versionCode = versionCode)
}
)
)
viewModel.purchase(requestedApp)
}
)
}

View File

@@ -206,16 +206,14 @@ class AppDetailsViewModel @Inject constructor(
}
}
fun download(app: App) {
viewModelScope.launch { downloadHelper.enqueueApp(app) }
}
fun purchase(app: App) {
viewModelScope.launch(Dispatchers.IO) {
try {
val files = purchaseHelper.purchase(app.packageName, app.versionCode, app.offerType)
_purchaseStatus.emit(files.isNotEmpty())
if (files.isNotEmpty()) download(app.copy(fileList = files.toMutableList()))
if (files.isNotEmpty()) {
downloadHelper.enqueueApp(app.copy(fileList = files.toMutableList()))
}
} catch (exception: Exception) {
_purchaseStatus.emit(false)
Log.e(TAG, "Failed to purchase the app", exception)