Skip to content

Commit 1709330

Browse files
committed
Remove references to opening a post by URL
1 parent 6771275 commit 1709330

File tree

8 files changed

+7
-99
lines changed

8 files changed

+7
-99
lines changed

Tests/KeystoneTests/Tests/Reader/ReaderDetailViewControllerTests.swift

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,6 @@ import Nimble
66

77
class ReaderDetailViewControllerTests: CoreDataTestCase {
88

9-
/// Given a post URL. returns a ReaderDetailViewController
10-
///
11-
func testControllerWithURL() {
12-
let url = URL(string: "https://wpmobilep2.wordpress.com/post")!
13-
14-
let controller = ReaderDetailViewController.controllerWithPostURL(url)
15-
16-
expect(controller).to(beAKindOf(ReaderDetailViewController.self))
17-
}
18-
199
/// Starts the coordinator with the ReaderPost and call start in viewDidLoad
2010
///
2111
func testControllerWithPostRendersPostContent() {

WordPress/Classes/System/Root View/ReaderPresenter.swift

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -294,8 +294,6 @@ public final class ReaderPresenter: NSObject, SplitViewDisplayable {
294294
viewModel.selection = .allSubscriptions
295295
case let .post(postID, siteID, isFeed):
296296
push(ReaderDetailViewController.controllerWithPostID(NSNumber(value: postID), siteID: NSNumber(value: siteID), isFeed: isFeed))
297-
case let .postURL(url):
298-
push(ReaderDetailViewController.controllerWithPostURL(url))
299297
case let .topic(topic):
300298
viewModel.selection = nil
301299
show(ReaderStreamViewController.controllerWithTopic(topic))

WordPress/Classes/Utility/Universal Links/RouteMatcher.swift

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ class RouteMatcher {
2525
func routesMatching(_ url: URL) -> [MatchedRoute] {
2626
let pathComponents = url.pathComponents
2727

28-
return routes.compactMap({ route in
28+
return routes.compactMap({ route -> MatchedRoute? in
2929
let values = valuesDictionary(forURL: url)
3030

3131
// If the paths are the same, we definitely have a match
@@ -40,23 +40,15 @@ class RouteMatcher {
4040
return nil
4141
}
4242

43-
guard let placeholderValues = placeholderDictionary(forKeyComponents: routeComponents,
44-
valueComponents: pathComponents) else {
45-
return nil
46-
}
47-
48-
let allValues = values.merging(placeholderValues,
49-
uniquingKeysWith: { (current, _) in current })
50-
51-
// If it's a wpcomPost reader route, then check if it's a valid wpcom url.
52-
// Need to check since we have no guarantee that it's a valid wpcom url,
53-
// other than the path having 4 components.
54-
if let readerRoute = route as? ReaderRoute,
55-
readerRoute == .wpcomPost,
56-
!readerRoute.isValidWpcomUrl(allValues) {
43+
guard let placeholderValues = placeholderDictionary(
44+
forKeyComponents: routeComponents,
45+
valueComponents: pathComponents
46+
) else {
5747
return nil
5848
}
5949

50+
let allValues = values.merging(placeholderValues, uniquingKeysWith: { (current, _) in current })
51+
6052
return route.matched(with: allValues)
6153
})
6254
}

WordPress/Classes/Utility/Universal Links/Routes+Reader.swift

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ enum ReaderRoute {
1515
case blog
1616
case feedsPost
1717
case blogsPost
18-
case wpcomPost
1918
}
2019

2120
extension ReaderRoute: Route {
@@ -47,8 +46,6 @@ extension ReaderRoute: Route {
4746
return "/read/feeds/:feed_id/posts/:post_id"
4847
case .blogsPost:
4948
return "/read/blogs/:blog_id/posts/:post_id"
50-
case .wpcomPost:
51-
return "/:post_year/:post_month/:post_day/:post_name"
5249
}
5350
}
5451

@@ -112,12 +109,6 @@ extension ReaderRoute: NavigationAction {
112109
if let (blogID, postID) = blogAndPostID(from: values) {
113110
presenter.showReader(path: .post(postID: postID, siteID: blogID))
114111
}
115-
case .wpcomPost:
116-
if let urlString = values[MatchedRouteURLComponentKey.url.rawValue],
117-
let url = URL(string: urlString),
118-
isValidWpcomUrl(values) {
119-
presenter.showReader(path: .postURL(url))
120-
}
121112
}
122113
}
123114

@@ -142,27 +133,6 @@ extension ReaderRoute: NavigationAction {
142133

143134
return (blogID, postID)
144135
}
145-
146-
func isValidWpcomUrl(_ values: [String: String]) -> Bool {
147-
let year = Int(values["post_year"] ?? "") ?? 0
148-
let month = Int(values["post_month"] ?? "") ?? 0
149-
let day = Int(values["post_day"] ?? "") ?? 0
150-
151-
// we assume no posts were made in the 1800's or earlier
152-
func isYear(_ year: Int) -> Bool {
153-
year > 1900
154-
}
155-
156-
func isMonth(_ month: Int) -> Bool {
157-
(1...12).contains(month)
158-
}
159-
160-
func isDay(_ day: Int) -> Bool {
161-
(1...31).contains(day)
162-
}
163-
164-
return isYear(year) && isMonth(month) && isDay(day)
165-
}
166136
}
167137

168138
// MARK: - RootViewPresenter (Extensions)

WordPress/Classes/Utility/Universal Links/UniversalLinkRouter.swift

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,6 @@ struct UniversalLinkRouter: LinkRouter {
8282
ReaderRoute.blog,
8383
ReaderRoute.feedsPost,
8484
ReaderRoute.blogsPost,
85-
ReaderRoute.wpcomPost
8685
]
8786

8887
static let statsRoutes: [Route] = [

WordPress/Classes/ViewRelated/Reader/Detail/ReaderDetailCoordinator.swift

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -476,8 +476,6 @@ class ReaderDetailCoordinator {
476476
presentWebViewController(url)
477477
} else if readerLinkRouter.canHandle(url: url) {
478478
readerLinkRouter.handle(url: url, shouldTrack: false, source: .inApp(presenter: viewController))
479-
} else if url.isWordPressDotComPost {
480-
presentReaderDetail(url)
481479
} else if url.isLinkProtocol {
482480
readerLinkRouter.handle(url: url, shouldTrack: false, source: .inApp(presenter: viewController))
483481
} else {
@@ -525,30 +523,6 @@ class ReaderDetailCoordinator {
525523
})
526524
}
527525

528-
/// Given a URL presents it in a new Reader detail screen
529-
///
530-
private func presentReaderDetail(_ url: URL) {
531-
532-
// In cross post Notifications, if the user tapped the link to the original post in the Notification body,
533-
// use the original post's info to display reader detail.
534-
// The API endpoint used by controllerWithPostID returns subscription flags for the post.
535-
// The API endpoint used by controllerWithPostURL does not return this information.
536-
// These flags are needed to display the `Follow conversation by email` option.
537-
// So if we can call controllerWithPostID, do so. Otherwise, fallback to controllerWithPostURL.
538-
// Ref: https://github.com/wordpress-mobile/WordPress-iOS/issues/17158
539-
540-
let readerDetail: ReaderDetailViewController = {
541-
if let post,
542-
selectedUrlIsCrossPost(url) {
543-
return ReaderDetailViewController.controllerWithPostID(post.crossPostMeta.postID, siteID: post.crossPostMeta.siteID)
544-
}
545-
546-
return ReaderDetailViewController.controllerWithPostURL(url)
547-
}()
548-
549-
viewController?.navigationController?.pushViewController(readerDetail, animated: true)
550-
}
551-
552526
private func selectedUrlIsCrossPost(_ url: URL) -> Bool {
553527
// Trim trailing slashes to facilitate URL comparison.
554528
let characterSet = CharacterSet(charactersIn: "/")

WordPress/Classes/ViewRelated/Reader/Detail/ReaderDetailViewController.swift

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -822,20 +822,6 @@ class ReaderDetailViewController: UIViewController, ReaderDetailView {
822822
return controller
823823
}
824824

825-
/// A View Controller that displays a Post content.
826-
///
827-
/// Use this method to present content for the user.
828-
/// - Parameter url: an URL of the post.
829-
/// - Returns: A `ReaderDetailViewController` instance
830-
@objc class func controllerWithPostURL(_ url: URL) -> ReaderDetailViewController {
831-
let controller = ReaderDetailViewController.loadFromStoryboard()
832-
let coordinator = ReaderDetailCoordinator(view: controller)
833-
coordinator.postURL = url
834-
controller.coordinator = coordinator
835-
836-
return controller
837-
}
838-
839825
/// Creates an instance from a Related post / Simple Post
840826
/// - Parameter simplePost: The related post object
841827
/// - Returns: If the related post URL is not valid

WordPress/Classes/ViewRelated/Reader/Navigation/ReaderNavigationPath.swift

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ enum ReaderNavigationPath: Hashable {
1010
case search
1111
case subscriptions
1212
case post(postID: Int, siteID: Int, isFeed: Bool = false)
13-
case postURL(URL)
1413
case topic(ReaderAbstractTopic)
1514
case tag(String)
1615
}

0 commit comments

Comments
 (0)