Skip to content

Commit 466e86f

Browse files
committed
Add loading indicator when opening deeplinks for reader
1 parent 8873de6 commit 466e86f

File tree

3 files changed

+6
-27
lines changed

3 files changed

+6
-27
lines changed

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -301,6 +301,9 @@ public final class ReaderPresenter: NSObject, SplitViewDisplayable {
301301
case let .tag(slug):
302302
viewModel.selection = nil
303303
show(ReaderStreamViewController.controllerWithTagSlug(slug))
304+
case let .site(siteID, isFeed):
305+
viewModel.selection = nil
306+
show(ReaderStreamViewController.controllerWithSiteID(NSNumber(value: siteID), isFeed: isFeed))
304307
}
305308
}
306309

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

Lines changed: 2 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -104,11 +104,11 @@ extension ReaderRoute: NavigationAction {
104104
}
105105
case .feed:
106106
if let feedIDValue = values["feed_id"], let feedID = Int(feedIDValue) {
107-
presenter.showReaderStream(with: feedID, isFeed: true)
107+
presenter.showReader(path: .site(siteID: feedID, isFeed: true))
108108
}
109109
case .blog:
110110
if let blogIDValue = values["blog_id"], let blogID = Int(blogIDValue) {
111-
presenter.showReaderStream(with: blogID, isFeed: false)
111+
presenter.showReader(path: .site(siteID: blogID, isFeed: false))
112112
}
113113
case .feedsPost:
114114
if let (feedID, postID) = feedAndPostID(from: values) {
@@ -167,29 +167,4 @@ private extension RootViewPresenter {
167167
showReader(path: .topic(topic))
168168
}
169169
}
170-
171-
/// - warning: This method performs the navigation asyncronously after
172-
/// fetching the information about the stream from the backend.
173-
func showReaderStream(with siteID: Int, isFeed: Bool) {
174-
getSiteTopic(siteID: NSNumber(value: siteID), isFeed: isFeed) { [weak self] topic in
175-
guard let topic else { return }
176-
self?.showReader(path: .topic(topic))
177-
}
178-
}
179-
180-
private func getSiteTopic(siteID: NSNumber, isFeed: Bool, completion: @escaping (ReaderSiteTopic?) -> Void) {
181-
let service = ReaderTopicService(coreDataStack: ContextManager.shared)
182-
service.siteTopicForSite(withID: siteID, isFeed: isFeed, success: { objectID, isFollowing in
183-
guard let objectID,
184-
let topic = try? ContextManager.shared.mainContext.existingObject(with: objectID) as? ReaderSiteTopic else {
185-
DDLogError("Reader: Error retriving site topic - invalid Site Id")
186-
completion(nil)
187-
return
188-
}
189-
completion(topic)
190-
}, failure: { error in
191-
DDLogError("Reader: Error retriving site topic - \(error?.localizedDescription ?? "unknown failure reason")")
192-
completion(nil)
193-
})
194-
}
195170
}

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ enum ReaderNavigationPath: Hashable {
1313
case postURL(URL)
1414
case topic(ReaderAbstractTopic)
1515
case tag(String)
16+
case site(siteID: Int, isFeed: Bool)
1617
}
1718

1819
extension ReaderNavigationPath {

0 commit comments

Comments
 (0)