TP-64079 | NIKHIL KUMAR | home page api cal behind login button loader [cherry pick from selective-refresh branch] (#10881)
Co-authored-by: Abhinav Gupta <abhinav.g@navi.com>
This commit is contained in:
@@ -24,7 +24,6 @@ import com.navi.base.utils.isNull
|
||||
import com.navi.base.utils.orFalse
|
||||
import com.navi.base.utils.orZero
|
||||
import com.navi.common.model.ModuleNameV2
|
||||
import com.navi.common.network.models.ErrorMessage
|
||||
import com.navi.common.utils.CommonNaviAnalytics
|
||||
import com.navi.common.utils.deviceId
|
||||
import com.navi.common.utils.fetchInstallerName
|
||||
@@ -45,9 +44,9 @@ import com.naviapp.utils.Constants.DEFAULT_WIDGET_TYPE
|
||||
import com.naviapp.utils.EMPTY
|
||||
import com.naviapp.utils.bundleToJson
|
||||
import com.naviapp.utils.extractQueryParams
|
||||
import okhttp3.internal.toImmutableMap
|
||||
import java.util.Locale
|
||||
import java.util.concurrent.ConcurrentHashMap
|
||||
import okhttp3.internal.toImmutableMap
|
||||
|
||||
@Keep
|
||||
class NaviAnalytics private constructor() {
|
||||
@@ -2742,6 +2741,11 @@ class NaviAnalytics private constructor() {
|
||||
mapOf(Pair("atTimeStamp", System.currentTimeMillis().toString()))
|
||||
)
|
||||
}
|
||||
fun onLoginHomePageApiCallTimeout() {
|
||||
NaviTrackEvent.trackEvent(
|
||||
"Login_Homepage_Home_Api_TimeOut"
|
||||
)
|
||||
}
|
||||
|
||||
fun onHomePageApiCalledFromUiTronAction() {
|
||||
NaviTrackEvent.trackEvent(
|
||||
|
||||
@@ -108,6 +108,7 @@ import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.ExperimentalCoroutinesApi
|
||||
import kotlinx.coroutines.Job
|
||||
import kotlinx.coroutines.TimeoutCancellationException
|
||||
import kotlinx.coroutines.delay
|
||||
import kotlinx.coroutines.flow.MutableSharedFlow
|
||||
import kotlinx.coroutines.flow.MutableStateFlow
|
||||
@@ -115,6 +116,7 @@ import kotlinx.coroutines.flow.asSharedFlow
|
||||
import kotlinx.coroutines.flow.asStateFlow
|
||||
import kotlinx.coroutines.flow.update
|
||||
import kotlinx.coroutines.launch
|
||||
import kotlinx.coroutines.withTimeout
|
||||
import timber.log.Timber
|
||||
import javax.inject.Inject
|
||||
|
||||
@@ -518,30 +520,37 @@ constructor(
|
||||
private suspend fun getHomeTabFromDatabase(): NaviCacheEntity? =
|
||||
naviCacheRepository.get(NaviSharedDbKeys.HOME_TAB.name)
|
||||
|
||||
fun fetchAndSaveHomeTab(
|
||||
fun fetchAndSaveHomeTabWithTimeOut(
|
||||
density: String? = null,
|
||||
connectivityType: String? = null,
|
||||
availableAppVersionCode: Int?,
|
||||
installedModules: String,
|
||||
clearReferralPopupPreferences: Boolean
|
||||
clearReferralPopupPreferences: Boolean,
|
||||
onComplete: (() -> Unit)? = null
|
||||
) {
|
||||
CoroutineScope(Dispatchers.IO).launch {
|
||||
val naviCacheAltSourceEntity =
|
||||
fetchHomeItemsFromAPI(
|
||||
density = density,
|
||||
connectivityType = connectivityType,
|
||||
availableAppVersionCode = availableAppVersionCode,
|
||||
installedModules = installedModules,
|
||||
clearReferralPopupPreferences = clearReferralPopupPreferences
|
||||
)
|
||||
|
||||
naviCacheRepository.save(
|
||||
NaviCacheEntity(
|
||||
key = NaviSharedDbKeys.HOME_TAB.name,
|
||||
value = naviCacheAltSourceEntity.value.orEmpty(),
|
||||
version = BuildConfig.VERSION_CODE
|
||||
)
|
||||
)
|
||||
try {
|
||||
withTimeout(5000) {
|
||||
val naviCacheAltSourceEntity = fetchHomeItemsFromAPI(
|
||||
density = density,
|
||||
connectivityType = connectivityType,
|
||||
availableAppVersionCode = availableAppVersionCode,
|
||||
installedModules = installedModules,
|
||||
clearReferralPopupPreferences = clearReferralPopupPreferences
|
||||
)
|
||||
naviCacheRepository.save(
|
||||
NaviCacheEntity(
|
||||
key = NaviSharedDbKeys.HOME_TAB.name,
|
||||
value = naviCacheAltSourceEntity.value.orEmpty(),
|
||||
version = BuildConfig.VERSION_CODE
|
||||
)
|
||||
)
|
||||
}
|
||||
} catch (e: TimeoutCancellationException) {
|
||||
naviAnalyticsEventTracker.onLoginHomePageApiCallTimeout()
|
||||
} finally {
|
||||
onComplete?.invoke()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -662,15 +662,16 @@ class RegistrationActivity :
|
||||
unblockInteractability()
|
||||
TemporaryStorageHelper.clear()
|
||||
AmcTaskManager.clearData(true)
|
||||
homeVM.fetchAndSaveHomeTab(
|
||||
homeVM.fetchAndSaveHomeTabWithTimeOut(
|
||||
density = getDensityName(context = this),
|
||||
connectivityType = getNetworkType(context = this),
|
||||
availableAppVersionCode =
|
||||
PreferenceManager.getIntPreferenceApp(CURRENT_VERSION_IN_STORE),
|
||||
PreferenceManager.getIntPreferenceApp(CURRENT_VERSION_IN_STORE),
|
||||
installedModules = getInstalledDynamicModulesCommaSeparated(),
|
||||
clearReferralPopupPreferences = false
|
||||
)
|
||||
goToNextScreen(nextCta = otpResponse.nextCta)
|
||||
) {
|
||||
goToNextScreen(nextCta = otpResponse.nextCta)
|
||||
}
|
||||
}
|
||||
.addOnFailureListener {
|
||||
analyticsTracker.trackNotificationAuthTokenSigninFailure(
|
||||
|
||||
Reference in New Issue
Block a user