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

Commit 9de5fed9 authored by Sayantan Roychowdhury's avatar Sayantan Roychowdhury
Browse files

issue_5413_2: Create getUpdatesOSS for updates

parent 9ce5d078
Loading
Loading
Loading
Loading
+20 −0
Original line number Diff line number Diff line
@@ -77,6 +77,26 @@ class UpdatesManagerImpl @Inject constructor(
        return Pair(updateList, status)
    }

    /*
     * Get updates only from cleanapk.
     * Issue: https://gitlab.e.foundation/e/backlog/-/issues/5413 [2]
     */
    suspend fun getUpdatesOSS(): Pair<List<FusedApp>, ResultStatus> {
        val updateList = mutableListOf<FusedApp>()
        val pkgList = pkgManagerModule.getAllUserApps().map { it.packageName }

        return if (pkgList.isNotEmpty()) {
            fusedAPIRepository.getApplicationDetailsOSS(pkgList).run {
                this.first.forEach {
                    if (it.status == Status.UPDATABLE) updateList.add(it)
                }
                Pair(updateList, this.second)
            }
        } else {
            Pair(listOf(), ResultStatus.OK)
        }
    }

    fun getApplicationCategoryPreference(): String {
        return fusedAPIRepository.getApplicationCategoryPreference()
    }
+4 −0
Original line number Diff line number Diff line
@@ -31,6 +31,10 @@ class UpdatesManagerRepository @Inject constructor(
        return updatesManagerImpl.getUpdates(authData)
    }

    suspend fun getUpdatesOSS(): Pair<List<FusedApp>, ResultStatus> {
        return updatesManagerImpl.getUpdatesOSS()
    }

    fun getApplicationCategoryPreference(): String {
        return updatesManagerImpl.getApplicationCategoryPreference()
    }