Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit abf94237 authored by Fahim M. Choudhury's avatar Fahim M. Choudhury Committed by Jonathan Klee
Browse files

refactor: update DownloadUrlRefresher to explicitly return false within the...

refactor: update DownloadUrlRefresher to explicitly return false within the error handler when an AppNotPurchased exception occurs.

Modify handleAppNotPurchased to return Unit instead of a hardcoded Boolean, moving the return logic to the call site for better clarity.
parent 3eec1a2f
Loading
Loading
Loading
Loading
Loading
+5 −3
Original line number Diff line number Diff line
@@ -65,7 +65,10 @@ class DownloadUrlRefresher @Inject constructor(
    ): Boolean {
        return when (throwable) {
            is CancellationException -> throw throwable
            is InternalException.AppNotPurchased -> handleAppNotPurchased(appInstall)
            is InternalException.AppNotPurchased -> {
                handleAppNotPurchased(appInstall)
                false
            }
            is Exception -> {
                val message = if (throwable is GplayHttpRequestException) {
                    "${appInstall.packageName} code: ${throwable.status} exception: ${throwable.message}"
@@ -81,7 +84,7 @@ class DownloadUrlRefresher @Inject constructor(
        }
    }

    private suspend fun handleAppNotPurchased(appInstall: AppInstall): Boolean {
    private suspend fun handleAppNotPurchased(appInstall: AppInstall) {
        if (appInstall.isFree) {
            appEventDispatcher.dispatch(AppEvent.AppRestrictedOrUnavailable(appInstall))
            appManager.addDownload(appInstall)
@@ -90,7 +93,6 @@ class DownloadUrlRefresher @Inject constructor(
            appManagerWrapper.addFusedDownloadPurchaseNeeded(appInstall)
            appEventDispatcher.dispatch(AppEvent.AppPurchaseEvent(appInstall))
        }
        return false
    }

    private suspend fun handleUpdateDownloadError(appInstall: AppInstall, isAnUpdate: Boolean) {