Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions WordPress/Classes/System/Root View/ReaderPresenter.swift
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,9 @@ public final class ReaderPresenter: NSObject, SplitViewDisplayable {
case let .tag(slug):
viewModel.selection = nil
show(ReaderStreamViewController.controllerWithTagSlug(slug))
case let .site(siteID, isFeed):
viewModel.selection = nil
show(ReaderStreamViewController.controllerWithSiteID(NSNumber(value: siteID), isFeed: isFeed))
}
}

Expand Down
29 changes: 2 additions & 27 deletions WordPress/Classes/Utility/Universal Links/Routes+Reader.swift
Original file line number Diff line number Diff line change
Expand Up @@ -104,11 +104,11 @@ extension ReaderRoute: NavigationAction {
}
case .feed:
if let feedIDValue = values["feed_id"], let feedID = Int(feedIDValue) {
presenter.showReaderStream(with: feedID, isFeed: true)
presenter.showReader(path: .site(siteID: feedID, isFeed: true))
}
case .blog:
if let blogIDValue = values["blog_id"], let blogID = Int(blogIDValue) {
presenter.showReaderStream(with: blogID, isFeed: false)
presenter.showReader(path: .site(siteID: blogID, isFeed: false))
}
case .feedsPost:
if let (feedID, postID) = feedAndPostID(from: values) {
Expand Down Expand Up @@ -167,29 +167,4 @@ private extension RootViewPresenter {
showReader(path: .topic(topic))
}
}

/// - warning: This method performs the navigation asyncronously after
/// fetching the information about the stream from the backend.
func showReaderStream(with siteID: Int, isFeed: Bool) {
getSiteTopic(siteID: NSNumber(value: siteID), isFeed: isFeed) { [weak self] topic in
guard let topic else { return }
self?.showReader(path: .topic(topic))
}
}

private func getSiteTopic(siteID: NSNumber, isFeed: Bool, completion: @escaping (ReaderSiteTopic?) -> Void) {
let service = ReaderTopicService(coreDataStack: ContextManager.shared)
service.siteTopicForSite(withID: siteID, isFeed: isFeed, success: { objectID, isFollowing in
guard let objectID,
let topic = try? ContextManager.shared.mainContext.existingObject(with: objectID) as? ReaderSiteTopic else {
DDLogError("Reader: Error retriving site topic - invalid Site Id")
completion(nil)
return
}
completion(topic)
}, failure: { error in
DDLogError("Reader: Error retriving site topic - \(error?.localizedDescription ?? "unknown failure reason")")
completion(nil)
})
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ enum ReaderNavigationPath: Hashable {
case postURL(URL)
case topic(ReaderAbstractTopic)
case tag(String)
case site(siteID: Int, isFeed: Bool)
}

extension ReaderNavigationPath {
Expand Down