Skip to content
This repository was archived by the owner on Sep 20, 2023. It is now read-only.

Commit

Permalink
log missing router and fix reference
Browse files Browse the repository at this point in the history
  • Loading branch information
rnystrom committed Nov 21, 2018
1 parent e9b6ac5 commit f28b119
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,7 @@ final class IssueReferencedSectionController: ListGenericSectionController<Issue
override func didSelectItem(at index: Int) {
guard let object = self.object else { return }
let model = IssueDetailsModel(owner: object.owner, repo: object.repo, number: object.number)
let controller = IssuesViewController(
client: client,
model: model
)
viewController?.show(controller, sender: nil)
viewController?.route_push(to: IssuesViewController(client: client, model: model))
}

}
27 changes: 14 additions & 13 deletions Classes/Systems/AppRouter/Router.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

import Foundation
import GitHawkRoutes
import Crashlytics

private func register<T: Routable & RoutePerformable>(
route: T.Type,
Expand All @@ -18,6 +19,16 @@ private func register<T: Routable & RoutePerformable>(

private var hasSwizzledChildViewController = false

private func logMissingRouter() {
let trace = Thread.callStackSymbols.joined(separator: "\n")
print("ERROR: Router not wired up. Callsite:")
print(trace)
Answers.logCustomEvent(
withName: "missing-router",
customAttributes: ["trace": trace]
)
}

extension UIViewController {

fileprivate class func swizzleChildViewController() {
Expand Down Expand Up @@ -68,30 +79,20 @@ extension UIViewController {
}
}

func route_push(route: Routable & RoutePerformable) {
if router == nil { print("ERROR: router was not wired up") }
router?.handle(route: route, from: self)
}

func route_detail(route: Routable & RoutePerformable) {
if router == nil { print("ERROR: router was not wired up") }
router?.handle(route: route, from: nil)
}

// MARK: Remove after migration

func route_push(to controller: UIViewController) {
if router == nil { print("ERROR: router was not wired up") }
if router == nil { logMissingRouter() }
router?.push(from: self, to: controller)
}

func route_detail(to controller: UIViewController) {
if router == nil { print("ERROR: router was not wired up") }
if router == nil { logMissingRouter() }
router?.detail(controller: controller)
}

func route_present(to controller: UIViewController) {
if router == nil { print("ERROR: router was not wired up") }
if router == nil { logMissingRouter() }
router?.present(from: self, to: controller)
}

Expand Down

1 comment on commit f28b119

@rnystrom
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Messed up and pushed straight to master. Finishes #2463

Please sign in to comment.