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

Commit 8458cf22 authored by Abhishek Aggarwal's avatar Abhishek Aggarwal
Browse files

fix: use string resources for Play Store unavailable category errors

parent fc29c70e
Loading
Loading
Loading
Loading
+6 −2
Original line number Diff line number Diff line
@@ -90,7 +90,7 @@ class CategoryApiImpl @Inject constructor(
        val playStoreRepository = awaitPlayStoreRepository()
            ?: return Pair(
                emptyList(),
                ResultStatus.UNKNOWN.apply { message = "Play Store unavailable" },
                ResultStatus.UNKNOWN.apply { message = getPlayStoreUnavailableMessage() },
            )
        val categoryList = mutableListOf<Category>()
        val result = handleNetworkResult {
@@ -161,7 +161,7 @@ class CategoryApiImpl @Inject constructor(
        pageUrl: String?
    ): ResultSupreme<Pair<List<Application>, String>> {
        val playStoreRepository = awaitPlayStoreRepository()
            ?: return ResultSupreme.Error("Play Store unavailable")
            ?: return ResultSupreme.Error(getPlayStoreUnavailableMessage())
        return handleNetworkResult {
            val cluster =
                playStoreRepository.getAppsByCategory(category, pageUrl)
@@ -177,6 +177,10 @@ class CategoryApiImpl @Inject constructor(
        }
    }

    private fun getPlayStoreUnavailableMessage(): String {
        return context.getString(R.string.play_store_unavailable)
    }

    /*
     * Filter out apps which are restricted, whose details cannot be fetched.
     * If an app is restricted, we do try to fetch the app details inside a
+1 −0
Original line number Diff line number Diff line
@@ -209,6 +209,7 @@
    <string name="too_many_requests_desc">The anonymous account you\'re currently using is unavailable. Please refresh the session to get another one.</string>
    <string name="account_unavailable">Account unavailable</string>
    <string name="refresh_session">REFRESH SESSION</string>
    <string name="play_store_unavailable">Play Store unavailable</string>
    <!--Data load error-->
    <string name="data_load_error">Error occurred while loading apps.</string>
    <string name="data_load_error_desc">This can be because server is not responding or other server error.\n\nPlease retry to try again, or try later.</string>
+5 −0
Original line number Diff line number Diff line
@@ -267,9 +267,14 @@ class CategoryApiTest {
            )
        )

        Mockito.`when`(
            context.getString(eq(R.string.play_store_unavailable))
        ).thenReturn("Play Store unavailable")

        val result = categoryApi.getGplayAppsByCategory("category", null)

        Assert.assertTrue(result.isUnknownError())
        Assert.assertEquals("Play Store unavailable", result.message)
        Mockito.verifyNoInteractions(playStoreRepository)
    }
}