Skip to content

Commit

Permalink
fix navigation crash
Browse files Browse the repository at this point in the history
  • Loading branch information
LivingWithHippos committed Aug 20, 2021
1 parent 7b8b8a8 commit aee9b21
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,11 @@ class ProtoStoreImpl @Inject constructor(
}

override suspend fun deleteCredentials() {
context.credentialsDataStore.updateData { it.toBuilder().clear().build() }
context.credentialsDataStore.updateData {
// fixme: using logout these lines do not work
it.toBuilder().clear().build()
// it.defaultInstanceForType
}
}

override suspend fun deleteIncompleteCredentials() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import com.github.livingwithhippos.unchained.data.model.AuthenticationStatus
import com.github.livingwithhippos.unchained.data.model.UserAction
import com.github.livingwithhippos.unchained.databinding.FragmentStartBinding
import dagger.hilt.android.AndroidEntryPoint
import timber.log.Timber

/**
* A simple [UnchainedFragment] subclass.
Expand All @@ -32,12 +33,24 @@ class StartFragment : UnchainedFragment() {
{
when (it.peekContent()) {
is AuthenticationStatus.Authenticated -> {
val action = StartFragmentDirections.actionStartFragmentToUserProfileFragment()
findNavController().navigate(action)
try {
val action =
StartFragmentDirections.actionStartFragmentToUserProfileFragment()
findNavController().navigate(action)
} catch (e: IllegalArgumentException) {
Timber.e("This could have been a crash")
// todo: fix this and remove this bypass
}
}
is AuthenticationStatus.AuthenticatedNoPremium -> {
val action = StartFragmentDirections.actionStartFragmentToUserProfileFragment()
findNavController().navigate(action)
try {
val action =
StartFragmentDirections.actionStartFragmentToUserProfileFragment()
findNavController().navigate(action)
} catch (e: IllegalArgumentException) {
Timber.e("This could have been a crash")
// todo: fix this and remove this bypass
}
}
is AuthenticationStatus.RefreshToken -> {
activityViewModel.refreshToken()
Expand Down

0 comments on commit aee9b21

Please sign in to comment.