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

Commit 48a62ca2 authored by Nishant Dande's avatar Nishant Dande
Browse files

Modified as per review comment

parent 57e08887
Loading
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -23,7 +23,7 @@ import foundation.e.apps.data.enums.User

interface CacheRepository {
    fun currentUser(): User
    fun cacheAuthData(): AuthData
    fun cachedAuthData(): AuthData
    fun resetCachedData()
    fun clearAuthData()
}
+1 −1
Original line number Diff line number Diff line
@@ -49,7 +49,7 @@ class CacheRepositoryImpl @Inject constructor(
        }
    }

    override fun cacheAuthData(): AuthData =
    override fun cachedAuthData(): AuthData =
        applicationContext.configurations.authData.let { data ->
            if (data.isEmpty()) throw RuntimeException("Auth Data not available")
            return data.toAuthData()
+1 −1
Original line number Diff line number Diff line
@@ -30,7 +30,7 @@ class AppInstallerUseCase@Inject constructor(

    fun currentAuthData(): AuthData? {
        return try {
            cacheRepository.cacheAuthData()
            cacheRepository.cachedAuthData()
        } catch (e: RuntimeException) {
            if (cacheRepository.currentUser() == User.NO_GOOGLE) {
                return AuthData("", "").apply {
+2 −2
Original line number Diff line number Diff line
@@ -56,7 +56,7 @@ class UserLoginUseCase @Inject constructor(
    fun retrieveCachedAuthData(): Flow<Resource<AuthData>> = flow {
        kotlin.runCatching {
            emit(Resource.Loading())
            emit(Resource.Success(cacheRepository.cacheAuthData()))
            emit(Resource.Success(cacheRepository.cachedAuthData()))
        }.onFailure { failure -> emit(Resource.Error(failure.localizedMessage)) }
    }

@@ -82,7 +82,7 @@ class UserLoginUseCase @Inject constructor(
                            }
                            is Resource.Loading -> emit(Resource.Loading())
                            is Resource.Success -> {
                                emit(Resource.Success(cacheRepository.cacheAuthData()))
                                emit(Resource.Success(cacheRepository.cachedAuthData()))
                            }
                        }
                    }.collect()
+1 −1
Original line number Diff line number Diff line
@@ -29,7 +29,7 @@ class MainActivityUseCase @Inject constructor(

    fun currentAuthData(): AuthData {
        return try {
            cacheRepository.cacheAuthData()
            cacheRepository.cachedAuthData()
        } catch (e: RuntimeException) {
            AuthData("", "")
        }
Loading