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

Commit 1bfdf316 authored by dev-12's avatar dev-12
Browse files

fix batch request causing error in update screen

parent ff95a726
Loading
Loading
Loading
Loading
+5 −3
Original line number Diff line number Diff line
@@ -104,12 +104,14 @@ class AppsApiImpl @Inject constructor(
        val applicationList = mutableListOf<Application>()

        val playStore = stores.getStore(Source.PLAY_STORE) as? PlayStoreRepository
        val apps = playStore?.getAppsDetails(packageNameList).orEmpty()
        val response = handleNetworkResult {
            playStore?.getAppsDetails(packageNameList).orEmpty()
        }
        val apps = response.data ?: emptyList()
        for (app in apps) {
            handleFilteredApps(app, applicationList)
        }

        return Pair(applicationList, ResultStatus.OK)
        return Pair(applicationList, response.getResultStatus())
    }

    /*
+5 −5
Original line number Diff line number Diff line
@@ -159,7 +159,7 @@ class PlayStoreRepository @Inject constructor(
        withContext(Dispatchers.IO) {
            var appDetails: List<GplayApp> = getAppDetailsHelper().getAppByPackageName(packageNames)

            if (!isEmulator() && appDetails.any { it.versionCode == 0L } && isAnonymousUser()) {
            if (!isEmulator() && appDetails.all { it.versionCode == 0L } && isAnonymousUser()) {
                // Google Play returns limited result ( i.e. version code being 0) with a stale token,
                // so we need to refresh authentication to get a new token.
                Timber.i("Version code is 0.")
@@ -168,13 +168,13 @@ class PlayStoreRepository @Inject constructor(

                appDetails = getAppDetailsHelper().getAppByPackageName(packageNames)

                if (appDetails.any { it.versionCode == 0L }) {
                    Timber.w("After refreshing auth, version code is still 0. Giving up installation.")
                    throw IllegalStateException("App version code cannot be 0")
                if (appDetails.all { it.versionCode == 0L }) {
                    Timber.w("After refreshing auth, version code is still 0.")
                }
            }

            appDetails.map { it.toApplication(context) }
            appDetails.filterNot { it.packageName.isBlank() || it.versionCode == 0L }
                .map { it.toApplication(context) }
        }

    override suspend fun getAppDetails(packageName: String): Application =