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:
@@ -92,7 +92,15 @@ fun ManualDownloadScreen(
|
|||||||
currentVersionCode = app!!.versionCode,
|
currentVersionCode = app!!.versionCode,
|
||||||
onNavigateUp = onNavigateUp,
|
onNavigateUp = onNavigateUp,
|
||||||
onDownload = { versionCode ->
|
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)
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -206,16 +206,14 @@ class AppDetailsViewModel @Inject constructor(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun download(app: App) {
|
|
||||||
viewModelScope.launch { downloadHelper.enqueueApp(app) }
|
|
||||||
}
|
|
||||||
|
|
||||||
fun purchase(app: App) {
|
fun purchase(app: App) {
|
||||||
viewModelScope.launch(Dispatchers.IO) {
|
viewModelScope.launch(Dispatchers.IO) {
|
||||||
try {
|
try {
|
||||||
val files = purchaseHelper.purchase(app.packageName, app.versionCode, app.offerType)
|
val files = purchaseHelper.purchase(app.packageName, app.versionCode, app.offerType)
|
||||||
_purchaseStatus.emit(files.isNotEmpty())
|
_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) {
|
} catch (exception: Exception) {
|
||||||
_purchaseStatus.emit(false)
|
_purchaseStatus.emit(false)
|
||||||
Log.e(TAG, "Failed to purchase the app", exception)
|
Log.e(TAG, "Failed to purchase the app", exception)
|
||||||
|
|||||||
Reference in New Issue
Block a user