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

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

refactor: fetching apps according to category

parent 7daf93c1
Loading
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -11,7 +11,7 @@ plugins {

def versionMajor = 2
def versionMinor = 4
def versionPatch = 7
def versionPatch = 9

def getGitHash = { ->
    def stdOut = new ByteArrayOutputStream()
+2 −0
Original line number Diff line number Diff line
@@ -22,4 +22,6 @@ interface StoreRepository {
    suspend fun getHomeScreenData(): Any
    suspend fun getSearchResult(query: String): Any
    suspend fun getSearchSuggestions(query: String): Any

    suspend fun getAppsByCategory(category: String, paginationParameter: Any? = null): Any
}
+11 −1
Original line number Diff line number Diff line
@@ -47,6 +47,16 @@ class CleanApkAppsRepository(
    }

    override suspend fun getSearchSuggestions(query: String): Any {
        TODO("Not yet implemented")
        return Any()
    }

    override suspend fun getAppsByCategory(category: String, paginationParameter: Any?): Response<Search> {
        return cleanAPKInterface.listApps(
            category,
            CleanAPKInterface.APP_SOURCE_FOSS,
            CleanAPKInterface.APP_TYPE_ANY,
            20,
            1
        )
    }
}
+10 −0
Original line number Diff line number Diff line
@@ -48,4 +48,14 @@ class CleanApkPWARepository(
    override suspend fun getSearchSuggestions(query: String): Any {
        TODO("Not yet implemented")
    }

    override suspend fun getAppsByCategory(category: String, paginationParameter: Any?): Any {
        return cleanAPKInterface.listApps(
            category,
            CleanAPKInterface.APP_SOURCE_FOSS,
            CleanAPKInterface.APP_TYPE_PWA,
            20,
            1
        )
    }
}
+9 −12
Original line number Diff line number Diff line
@@ -562,7 +562,7 @@ class FusedAPIImpl @Inject constructor(
        var streamBundle = StreamBundle()
        val status = runCodeBlockWithTimeout({
            streamBundle =
                gPlayAPIRepository.getNextStreamBundle(authData, homeUrl, currentStreamBundle)
                gplayRepository.getAppsByCategory(homeUrl, currentStreamBundle) as StreamBundle
        })
        return ResultSupreme.create(status, streamBundle)
    }
@@ -575,7 +575,7 @@ class FusedAPIImpl @Inject constructor(
        var streamCluster = StreamCluster()
        val status = runCodeBlockWithTimeout({
            streamCluster =
                gPlayAPIRepository.getAdjustedFirstCluster(authData, streamBundle, pointer)
                gplayRepository.getAppsByCategory("", Pair(streamBundle, pointer)) as StreamCluster
        })
        return ResultSupreme.create(status, streamCluster)
    }
@@ -586,7 +586,8 @@ class FusedAPIImpl @Inject constructor(
    ): ResultSupreme<StreamCluster> {
        var streamCluster = StreamCluster()
        val status = runCodeBlockWithTimeout({
            streamCluster = gPlayAPIRepository.getNextStreamCluster(authData, currentStreamCluster)
            streamCluster =
                gplayRepository.getAppsByCategory("", currentStreamCluster) as StreamCluster
        })
        return ResultSupreme.create(status, streamCluster)
    }
@@ -598,7 +599,7 @@ class FusedAPIImpl @Inject constructor(
        val list = mutableListOf<FusedApp>()
        val status = runCodeBlockWithTimeout({
            list.addAll(
                gPlayAPIRepository.listApps(browseUrl, authData).map { app ->
                (gplayRepository.getAppsByCategory(browseUrl) as List<App>).map { app ->
                    app.transformToFusedApp()
                }
            )
@@ -1139,19 +1140,15 @@ class FusedAPIImpl @Inject constructor(
    }

    private suspend fun getOpenSourceAppsResponse(category: String): Search? {
        return cleanAPKRepository.listApps(
        return (cleanApkAppsRepository.getAppsByCategory(
            category,
            CleanAPKInterface.APP_SOURCE_FOSS,
            CleanAPKInterface.APP_TYPE_ANY
        ).body()
        ) as Response<Search>).body()
    }

    private suspend fun getPWAAppsResponse(category: String): Search? {
        return cleanAPKRepository.listApps(
        return (cleanApkPWARepository.getAppsByCategory(
            category,
            CleanAPKInterface.APP_SOURCE_ANY,
            CleanAPKInterface.APP_TYPE_PWA
        ).body()
        ) as Response<Search>).body()
    }

    private fun Category.transformToFusedCategory(): FusedCategory {
Loading