NTP-28755 | add isCachedDataAvailable check in nae (#14545)
This commit is contained in:
@@ -28,6 +28,7 @@ constructor(@SuperAppRetroFit private val superAppRetrofitService: RetrofitServi
|
||||
isScreenLockEnabled: Boolean,
|
||||
isMobileScreenLockSet: Boolean,
|
||||
naeScreenName: String,
|
||||
isCachedDataAvailable: Boolean,
|
||||
): RepoResult<ScreenDefinition> {
|
||||
return apiResponseCallback(
|
||||
superAppRetrofitService.fetchProfileForgeScreen(
|
||||
@@ -38,7 +39,10 @@ constructor(@SuperAppRetroFit private val superAppRetrofitService: RetrofitServi
|
||||
screenId = PROFILE_SCREEN,
|
||||
),
|
||||
metricInfo =
|
||||
MetricInfo.AppMetric(screen = naeScreenName, isNae = { !it.isSuccessWithData() }),
|
||||
MetricInfo.AppMetric(
|
||||
screen = naeScreenName,
|
||||
isNae = { isCachedDataAvailable.not() && !it.isSuccessWithData() },
|
||||
),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,6 +12,7 @@ import com.google.gson.Gson
|
||||
import com.navi.base.cache.model.NaviCacheEntity
|
||||
import com.navi.base.cache.repository.NaviCacheRepository
|
||||
import com.navi.base.cache.util.NaviSharedDbKeys
|
||||
import com.navi.base.utils.isNotNullAndNotEmpty
|
||||
import com.navi.common.commoncomposables.utils.resetScrollToTop
|
||||
import com.navi.common.network.models.RepoResult
|
||||
import com.navi.common.utils.BiometricPromptUtils
|
||||
@@ -131,23 +132,23 @@ constructor(
|
||||
naeScreenName: String,
|
||||
) {
|
||||
coroutineScope.launch(Dispatchers.IO) {
|
||||
if (canCachedDataBeUsed) {
|
||||
val profilePageResponse =
|
||||
naviCacheRepository.get(key = NaviSharedDbKeys.NAVI_APP_PROFILE.keyName)
|
||||
if (profilePageResponse?.value != null) {
|
||||
cacheResponse =
|
||||
dataDeserializers.fromJson(
|
||||
profilePageResponse.value,
|
||||
ScreenDefinition::class.java,
|
||||
)
|
||||
_profileScreenDataState.update { ProfileScreenState.Success(cacheResponse) }
|
||||
}
|
||||
canCachedDataBeUsed = true
|
||||
val profilePageResponse =
|
||||
naviCacheRepository.get(key = NaviSharedDbKeys.NAVI_APP_PROFILE.keyName)
|
||||
val isCacheValid =
|
||||
canCachedDataBeUsed && profilePageResponse?.value.isNotNullAndNotEmpty()
|
||||
if (isCacheValid) {
|
||||
val cacheResponse =
|
||||
dataDeserializers.fromJson(
|
||||
profilePageResponse?.value,
|
||||
ScreenDefinition::class.java,
|
||||
)
|
||||
_profileScreenDataState.update { ProfileScreenState.Success(cacheResponse) }
|
||||
}
|
||||
getProfileResponseFromApi(
|
||||
isScreenLockEnabled = isScreenLockEnabled,
|
||||
isMobileScreenLockSet = isMobileScreenLockSet,
|
||||
naeScreenName = naeScreenName,
|
||||
isCachedDataAvailable = isCacheValid,
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -167,12 +168,14 @@ constructor(
|
||||
isScreenLockEnabled: Boolean,
|
||||
isMobileScreenLockSet: Boolean,
|
||||
naeScreenName: String,
|
||||
isCachedDataAvailable: Boolean,
|
||||
) {
|
||||
val response =
|
||||
repository.fetchProfileItems(
|
||||
isScreenLockEnabled = isScreenLockEnabled,
|
||||
isMobileScreenLockSet = isMobileScreenLockSet,
|
||||
naeScreenName = naeScreenName,
|
||||
isCachedDataAvailable = isCachedDataAvailable,
|
||||
)
|
||||
if (response.isValidResponse()) {
|
||||
if (::cacheResponse.isInitialized) {
|
||||
|
||||
Reference in New Issue
Block a user