@@ -18,6 +18,16 @@ class RepositoryDetailViewController: UIViewController, StoreSubscriber {
1818
1919var repository : Repository ?
2020
21+ override func didMoveToParentViewController( parent: UIViewController ? ) {
22+ if parent== nil {
23+ // Required to update the route, when this VC was dismissed through back button from
24+ // NavigationController, since we can't intercept the back button
25+ if store. state. navigationState. route== [ mainViewRoute, repositoryDetailRoute] {
26+ store. dispatch ( SetRouteAction ( [ mainViewRoute] ) )
27+ }
28+ }
29+ }
30+
2131override func viewWillAppear( animated: Bool ) {
2232 super. viewWillAppear ( animated)
2333
@@ -33,12 +43,6 @@ class RepositoryDetailViewController: UIViewController, StoreSubscriber {
3343 super. viewWillDisappear ( animated)
3444
3545 store. unsubscribe ( self )
36-
37- // Required to update the route, when this VC was dismissed through back button from
38- // NavigationController, since we can't intercept the back button
39- if store. state. navigationState. route== [ mainViewRoute, repositoryDetailRoute] {
40- store. dispatch ( SetRouteAction ( [ mainViewRoute] ) )
41- }
4246}
4347
4448func newState( state: ( selectedRepository: Repository ? , bookmarks: [ Bookmark ] ) ) {