1
0
Fork 0

For #490 - Fixes navigation when selecting a history item

master
Jeff Boek 2019-02-13 13:36:07 -08:00 committed by Colin Lee
parent 06403f3b3f
commit a4a9222a94
2 changed files with 14 additions and 3 deletions

View File

@ -74,7 +74,13 @@ class Core(private val context: Context) {
} }
// There's an active bundle with a snapshot: Feed it into the SessionManager. // There's an active bundle with a snapshot: Feed it into the SessionManager.
snapshot.await()?.let { sessionManager.restore(it) } snapshot.await()?.let {
try {
sessionManager.restore(it)
} catch (_: IllegalArgumentException) {
return@let
}
}
// Now that we have restored our previous state (if there's one) let's setup auto saving the state while // Now that we have restored our previous state (if there's one) let's setup auto saving the state while
// the app is used. // the app is used.

View File

@ -14,6 +14,7 @@ import android.view.View
import android.view.ViewGroup import android.view.ViewGroup
import androidx.appcompat.app.AppCompatActivity import androidx.appcompat.app.AppCompatActivity
import androidx.fragment.app.Fragment import androidx.fragment.app.Fragment
import androidx.navigation.NavOptions
import androidx.navigation.Navigation import androidx.navigation.Navigation
import kotlinx.android.synthetic.main.fragment_history.view.* import kotlinx.android.synthetic.main.fragment_history.view.*
import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.CoroutineScope
@ -54,8 +55,12 @@ class HistoryFragment : Fragment(), CoroutineScope {
getSafeManagedObservable<HistoryAction>() getSafeManagedObservable<HistoryAction>()
.subscribe { .subscribe {
if (it is HistoryAction.Select) { if (it is HistoryAction.Select) {
Navigation.findNavController(requireActivity(), R.id.container) Navigation.findNavController(requireActivity(), R.id.container).apply {
.popBackStack(R.id.browserFragment, false) navigate(
HistoryFragmentDirections.actionGlobalBrowser(null),
NavOptions.Builder().setPopUpTo(R.id.homeFragment, false).build()
)
}
requireComponents.useCases.sessionUseCases.loadUrl.invoke(it.item.url) requireComponents.useCases.sessionUseCases.loadUrl.invoke(it.item.url)
} }