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

Commit e30aa525 authored by Nishant Dande's avatar Nishant Dande
Browse files

Modify as per review comment

parent 4b732ebe
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
@@ -1229,7 +1229,7 @@ class FusedApiImpl @Inject constructor(
     * Recommended to use this instead of [PkgManagerModule.getPackageStatus].
     */
    override fun getFusedAppInstallationStatus(fusedApp: FusedApp): Status {
        return if (fusedApp.is_pwa) {
        return if (fusedApp.isPwa) {
            pwaManagerModule.getPwaStatus(fusedApp)
        } else {
            pkgManagerModule.getPackageStatus(fusedApp.package_name, fusedApp.latest_version_code)
@@ -1243,12 +1243,12 @@ class FusedApiImpl @Inject constructor(
    }

    private fun FusedApp.updateType() {
        this.type = if (this.is_pwa) Type.PWA else Type.NATIVE
        this.type = if (this.isPwa) Type.PWA else Type.NATIVE
    }

    private fun FusedApp.updateSource() {
        this.apply {
            source = if (origin == Origin.CLEANAPK && is_pwa) {
            source = if (origin == Origin.CLEANAPK && isPwa) {
                context.getString(R.string.pwa)
            } else if (origin == Origin.CLEANAPK) {
                context.getString(R.string.open_source)
+1 −1
Original line number Diff line number Diff line
@@ -52,7 +52,7 @@ data class FusedApp(
    var source: String = String(),
    val price: String = String(),
    val isFree: Boolean = true,
    val is_pwa: Boolean = false,
    val isPwa: Boolean = false,
    var pwaPlayerDbId: Long = -1,
    val url: String = String(),
    var type: Type = Type.NATIVE,
+6 −12
Original line number Diff line number Diff line
@@ -34,16 +34,14 @@ class UserLoginUseCase @Inject constructor(
) {

    fun anonymousUser(): Flow<Resource<AuthData>> = flow {
        try {
        kotlin.runCatching {
            emit(Resource.Loading())
            emit(Resource.Success(loginRepository.anonymousUser()))
        } catch (e: Exception) {
            emit(Resource.Error(e.localizedMessage))
        }
        }.onFailure { failure -> emit(Resource.Error(failure.localizedMessage)) }
    }

    fun googleUser(authData: AuthData, token: String): Flow<Resource<Unit>> = flow {
        try {
        kotlin.runCatching {
            emit(
                Resource.Success(
                    loginRepository.googleUser(
@@ -52,18 +50,14 @@ class UserLoginUseCase @Inject constructor(
                    )
                )
            )
        } catch (e: Exception) {
            emit(Resource.Error(e.localizedMessage))
        }
        }.onFailure { failure -> emit(Resource.Error(failure.localizedMessage)) }
    }

    fun retrieveCachedAuthData(): Flow<Resource<AuthData>> = flow {
        try {
        kotlin.runCatching {
            emit(Resource.Loading())
            emit(Resource.Success(cacheRepository.cacheAuthData()))
        } catch (e: Exception) {
            emit(Resource.Error(e.localizedMessage))
        }
        }.onFailure { failure -> emit(Resource.Error(failure.localizedMessage)) }
    }

    fun logoutUser() {
+1 −0
Original line number Diff line number Diff line
@@ -135,6 +135,7 @@ class LoginViewModel @Inject constructor(
     */
    fun initialNoGoogleLogin(onUserSaved: () -> Unit) {
        viewModelScope.launch {
            loginSourceRepository.setNoGoogleMode()
            val authObject = noGoogleModeUseCase.performNoGoogleLogin()
            _loginState.value = LoginState(isLoading = false, isLoggedIn = true)
            authObjects.postValue(listOf(authObject))
+1 −1
Original line number Diff line number Diff line
@@ -754,7 +754,7 @@ class ApplicationFragment : Fragment(R.layout.fragment_application) {
            backgroundTintList =
                ContextCompat.getColorStateList(view.context, R.color.colorAccent)
            setOnClickListener {
                if (fusedApp.is_pwa) {
                if (fusedApp.isPwa) {
                    pwaManagerModule.launchPwa(fusedApp)
                } else {
                    startActivity(pkgManagerModule.getLaunchIntent(fusedApp.package_name))
Loading