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

Commit cf8efa72 authored by Sayantan Roychowdhury's avatar Sayantan Roychowdhury
Browse files

wrap in handleNetworkResult

parent 7cdf58ba
Loading
Loading
Loading
Loading
+20 −9
Original line number Diff line number Diff line
@@ -25,6 +25,7 @@ import foundation.e.apps.data.application.data.Application
import foundation.e.apps.data.gitlab.models.SystemAppInfo
import foundation.e.apps.data.gitlab.models.SystemAppProject
import foundation.e.apps.data.gitlab.models.toApplication
import foundation.e.apps.data.handleNetworkResult
import foundation.e.apps.install.pkg.AppLoungePackageManager
import foundation.e.apps.utils.SystemInfoProvider
import javax.inject.Inject
@@ -43,11 +44,13 @@ class SystemAppsUpdatesRepository @Inject constructor(
    private var systemAppProjectList = mutableListOf<SystemAppProject>()

    suspend fun fetchAllEligibleApps() {
        handleNetworkResult {
            val response = eligibleSystemAppsApi.getAllEligibleApps()
            if (response.isSuccessful && !response.body().isNullOrEmpty()) {
                response.body()?.let { systemAppProjectList.addAll(it) }
            }
        }
    }

    fun getAllEligibleApps(): List<String> {
        return systemAppProjectList.map { it.packageName }
@@ -116,16 +119,24 @@ class SystemAppsUpdatesRepository @Inject constructor(
                return@forEach
            }

            val result = handleNetworkResult {
                getSystemAppUpdateInfo(
                    it,
                    releaseType,
                    sdkLevel,
                    device,
            )?.run {
                )
            }

            result.data?.run {
                applicationDataManager.updateStatus(this)
                updateList.add(this)
                updateSource(context)
            }

            if (!result.isSuccess()) {
                Timber.e("Failed to get system app info for $it - ${result.message}")
            }
        }

        return updateList