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

Commit c219119b authored by Hasib Prince's avatar Hasib Prince
Browse files

error handling updated for all gplay apis

parent ea7f47e2
Loading
Loading
Loading
Loading
Loading
+19 −26
Original line number Diff line number Diff line
@@ -694,7 +694,7 @@ class FusedApiImpl @Inject constructor(
        appList: List<App>,
    ): ResultSupreme<List<FusedApp>> {
        val filteredFusedApps = mutableListOf<FusedApp>()
        val status = runCodeWithTimeout({
        return handleResultFromAppSources {
            appList.forEach {
                val filter = getAppFilterLevel(it, authData)
                if (filter.isUnFiltered()) {
@@ -705,9 +705,8 @@ class FusedApiImpl @Inject constructor(
                    )
                }
            }
        })

        return ResultSupreme.create(status, filteredFusedApps)
            filteredFusedApps
        }
    }

    /**
@@ -786,7 +785,7 @@ class FusedApiImpl @Inject constructor(

        var response: FusedApp? = null

        val status = runCodeWithTimeout({
        val result = handleResultFromAppSources {
            response = if (origin == Origin.CLEANAPK) {
                (cleanApkAppsRepository.getAppDetails(id) as Response<Application>).body()?.app
            } else {
@@ -799,9 +798,10 @@ class FusedApiImpl @Inject constructor(
                it.updateSource()
                it.updateFilterLevel(authData)
            }
        })
            response
        }

        return Pair(response ?: FusedApp(), status)
        return Pair(result.data ?: FusedApp(), result.getResultStatus())
    }

    /*
@@ -839,9 +839,9 @@ class FusedApiImpl @Inject constructor(
            val gplayCategoryResult = fetchGplayCategories(
                type,
            )
            categoriesList.addAll(gplayCategoryResult.second)
            apiStatus = gplayCategoryResult.first
            errorApplicationCategory = gplayCategoryResult.third
            categoriesList.addAll(gplayCategoryResult.data ?: listOf())
            apiStatus = gplayCategoryResult.getResultStatus()
            errorApplicationCategory = APP_TYPE_ANY
        }

        return Pair(apiStatus, errorApplicationCategory)
@@ -849,25 +849,18 @@ class FusedApiImpl @Inject constructor(

    private suspend fun fetchGplayCategories(
        type: CategoryType,
    ): Triple<ResultStatus, List<FusedCategory>, String> {
        var errorApplicationCategory = ""
        var apiStatus = ResultStatus.OK
    ): ResultSupreme<List<FusedCategory>> {
        val categoryList = mutableListOf<FusedCategory>()
        runCodeWithTimeout({

        return handleResultFromAppSources {
            val playResponse = gplayRepository.getCategories(type).map { app ->
                val category = app.transformToFusedCategory()
                updateCategoryDrawable(category)
                category
            }
            categoryList.addAll(playResponse)
        }, {
            errorApplicationCategory = APP_TYPE_ANY
            apiStatus = ResultStatus.TIMEOUT
        }, {
            errorApplicationCategory = APP_TYPE_ANY
            apiStatus = ResultStatus.UNKNOWN
        })
        return Triple(apiStatus, categoryList, errorApplicationCategory)
            categoryList
        }
    }

    private suspend fun fetchPWACategories(
@@ -1131,6 +1124,7 @@ class FusedApiImpl @Inject constructor(
            is SocketTimeoutException -> "Timeout"
            else -> "Unknown"
        }

        return (e.localizedMessage?.ifBlank { ERROR_GPLAY_API }
            ?: ERROR_GPLAY_API) + "Status: $status"
    }
@@ -1437,7 +1431,7 @@ class FusedApiImpl @Inject constructor(
        var fusedAppList: MutableList<FusedApp> = mutableListOf()
        var nextPageUrl = ""

        val status = runCodeWithTimeout({
        return handleResultFromAppSources {
            val streamCluster =
                gplayRepository.getAppsByCategory(category, pageUrl) as StreamCluster

@@ -1450,8 +1444,7 @@ class FusedApiImpl @Inject constructor(
            if (!nextPageUrl.isNullOrEmpty()) {
                fusedAppList.add(FusedApp(isPlaceHolder = true))
            }
        })

        return ResultSupreme.create(status, Pair(fusedAppList, nextPageUrl))
            Pair(fusedAppList, nextPageUrl)
        }
    }
}