Loading app/src/main/java/foundation/e/apps/ui/parentFragment/LegacyLoadFailure.kt +20 −0 Original line number Diff line number Diff line Loading @@ -48,6 +48,7 @@ data class LegacyLoadFailure( val storeType: StoreType? = null, val authError: AuthError? = null, val loginMode: PlayStoreLoginMode? = null, val storesToResetOnRetry: List<AuthStore> = emptyList(), @StringRes val dialogTitleRes: Int = R.string.data_load_error, @StringRes val dialogMessageRes: Int = R.string.data_load_error_desc, ) { Loading @@ -74,6 +75,10 @@ data class LegacyLoadFailure( storeType = storeType, authError = authError, loginMode = loginMode, storesToResetOnRetry = resolveStoresToResetOnRetry( exception = exception, authError = authError, ), dialogTitleRes = dialogSpec.titleRes, dialogMessageRes = dialogSpec.messageRes, ) Loading Loading @@ -237,6 +242,21 @@ private fun resolveDialogSpec( } } private fun resolveStoresToResetOnRetry( exception: Exception, authError: AuthError?, ): List<AuthStore> { return when { authError is AuthError.InvalidToken && authError.store == AuthStore.PLAY_STORE -> listOf(AuthStore.PLAY_STORE) exception is GPlayValidationException -> listOf(AuthStore.PLAY_STORE) else -> emptyList() } } private data class LegacyLoadDialogSpec( @StringRes val titleRes: Int = R.string.data_load_error, @StringRes val messageRes: Int = R.string.data_load_error_desc, Loading app/src/main/java/foundation/e/apps/ui/parentFragment/LegacyLoadFailureDialogs.kt +1 −6 Original line number Diff line number Diff line Loading @@ -31,10 +31,8 @@ import androidx.lifecycle.Observer import foundation.e.apps.R import foundation.e.apps.data.login.core.StoreType import foundation.e.apps.data.login.exceptions.GPlayLoginException import foundation.e.apps.data.login.exceptions.GPlayValidationException import foundation.e.apps.data.system.NetworkStatusManager import foundation.e.apps.databinding.DialogErrorLogBinding import foundation.e.apps.domain.auth.AuthStore import foundation.e.apps.domain.auth.PlayStoreLoginMode import foundation.e.apps.feature.auth.login.LoginUiEvent import foundation.e.apps.feature.auth.login.LoginViewModel Loading Loading @@ -191,10 +189,7 @@ class LegacyLoadFailureDialogs( setView(dialogView.root) setPositiveButton(R.string.retry) { _, _ -> callbacks.showLoading() when (exception) { is GPlayValidationException -> sessionViewModel.refreshSessions(listOf(AuthStore.PLAY_STORE)) else -> sessionViewModel.refreshSessions() } sessionViewModel.refreshSessions(failure.storesToResetOnRetry) } setNegativeButton(R.string.logout) { _, _ -> loginViewModel.onEvent(LoginUiEvent.LogoutRequested) Loading app/src/test/java/foundation/e/apps/ui/parentFragment/LegacyLoadFailureTest.kt +16 −0 Original line number Diff line number Diff line Loading @@ -52,6 +52,7 @@ class LegacyLoadFailureTest { assertThat(failure.kind).isEqualTo(LegacyLoadFailureKind.SIGN_IN) assertThat(failure.loginMode).isEqualTo(PlayStoreLoginMode.MICROG) assertThat(failure.exception).isInstanceOf(GPlayValidationException::class.java) assertThat(failure.storesToResetOnRetry).containsExactly(AuthStore.PLAY_STORE) } @Test Loading Loading @@ -80,5 +81,20 @@ class LegacyLoadFailureTest { assertThat(failure.kind).isEqualTo(LegacyLoadFailureKind.SIGN_IN) assertThat(failure.loginMode).isEqualTo(PlayStoreLoginMode.ANONYMOUS) assertThat(failure.storesToResetOnRetry).containsExactly(AuthStore.PLAY_STORE) } @Test fun `login required failures keep full session retry scope`() { val failure = AuthError.LoginRequired( store = AuthStore.PLAY_STORE, message = "sign in again", ).toLegacyLoadFailure( storeType = StoreType.PLAY_STORE, loginMode = PlayStoreLoginMode.GOOGLE, ) assertThat(failure.kind).isEqualTo(LegacyLoadFailureKind.SIGN_IN) assertThat(failure.storesToResetOnRetry).isEmpty() } } Loading
app/src/main/java/foundation/e/apps/ui/parentFragment/LegacyLoadFailure.kt +20 −0 Original line number Diff line number Diff line Loading @@ -48,6 +48,7 @@ data class LegacyLoadFailure( val storeType: StoreType? = null, val authError: AuthError? = null, val loginMode: PlayStoreLoginMode? = null, val storesToResetOnRetry: List<AuthStore> = emptyList(), @StringRes val dialogTitleRes: Int = R.string.data_load_error, @StringRes val dialogMessageRes: Int = R.string.data_load_error_desc, ) { Loading @@ -74,6 +75,10 @@ data class LegacyLoadFailure( storeType = storeType, authError = authError, loginMode = loginMode, storesToResetOnRetry = resolveStoresToResetOnRetry( exception = exception, authError = authError, ), dialogTitleRes = dialogSpec.titleRes, dialogMessageRes = dialogSpec.messageRes, ) Loading Loading @@ -237,6 +242,21 @@ private fun resolveDialogSpec( } } private fun resolveStoresToResetOnRetry( exception: Exception, authError: AuthError?, ): List<AuthStore> { return when { authError is AuthError.InvalidToken && authError.store == AuthStore.PLAY_STORE -> listOf(AuthStore.PLAY_STORE) exception is GPlayValidationException -> listOf(AuthStore.PLAY_STORE) else -> emptyList() } } private data class LegacyLoadDialogSpec( @StringRes val titleRes: Int = R.string.data_load_error, @StringRes val messageRes: Int = R.string.data_load_error_desc, Loading
app/src/main/java/foundation/e/apps/ui/parentFragment/LegacyLoadFailureDialogs.kt +1 −6 Original line number Diff line number Diff line Loading @@ -31,10 +31,8 @@ import androidx.lifecycle.Observer import foundation.e.apps.R import foundation.e.apps.data.login.core.StoreType import foundation.e.apps.data.login.exceptions.GPlayLoginException import foundation.e.apps.data.login.exceptions.GPlayValidationException import foundation.e.apps.data.system.NetworkStatusManager import foundation.e.apps.databinding.DialogErrorLogBinding import foundation.e.apps.domain.auth.AuthStore import foundation.e.apps.domain.auth.PlayStoreLoginMode import foundation.e.apps.feature.auth.login.LoginUiEvent import foundation.e.apps.feature.auth.login.LoginViewModel Loading Loading @@ -191,10 +189,7 @@ class LegacyLoadFailureDialogs( setView(dialogView.root) setPositiveButton(R.string.retry) { _, _ -> callbacks.showLoading() when (exception) { is GPlayValidationException -> sessionViewModel.refreshSessions(listOf(AuthStore.PLAY_STORE)) else -> sessionViewModel.refreshSessions() } sessionViewModel.refreshSessions(failure.storesToResetOnRetry) } setNegativeButton(R.string.logout) { _, _ -> loginViewModel.onEvent(LoginUiEvent.LogoutRequested) Loading
app/src/test/java/foundation/e/apps/ui/parentFragment/LegacyLoadFailureTest.kt +16 −0 Original line number Diff line number Diff line Loading @@ -52,6 +52,7 @@ class LegacyLoadFailureTest { assertThat(failure.kind).isEqualTo(LegacyLoadFailureKind.SIGN_IN) assertThat(failure.loginMode).isEqualTo(PlayStoreLoginMode.MICROG) assertThat(failure.exception).isInstanceOf(GPlayValidationException::class.java) assertThat(failure.storesToResetOnRetry).containsExactly(AuthStore.PLAY_STORE) } @Test Loading Loading @@ -80,5 +81,20 @@ class LegacyLoadFailureTest { assertThat(failure.kind).isEqualTo(LegacyLoadFailureKind.SIGN_IN) assertThat(failure.loginMode).isEqualTo(PlayStoreLoginMode.ANONYMOUS) assertThat(failure.storesToResetOnRetry).containsExactly(AuthStore.PLAY_STORE) } @Test fun `login required failures keep full session retry scope`() { val failure = AuthError.LoginRequired( store = AuthStore.PLAY_STORE, message = "sign in again", ).toLegacyLoadFailure( storeType = StoreType.PLAY_STORE, loginMode = PlayStoreLoginMode.GOOGLE, ) assertThat(failure.kind).isEqualTo(LegacyLoadFailureKind.SIGN_IN) assertThat(failure.storesToResetOnRetry).isEmpty() } }