Skip to content

Commit 5463261

Browse files
committed
[RepositoryDetail] Change Back Button Implementation
1 parent 1a3dbd5 commit 5463261

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

SwiftFlowGitHubBrowser/ViewControllers/RepositoryDetailViewController.swift

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,16 @@ class RepositoryDetailViewController: UIViewController, StoreSubscriber {
1818

1919
var 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+
2131
override 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

4448
func newState(state: (selectedRepository: Repository?, bookmarks: [Bookmark])) {

0 commit comments

Comments
 (0)