Skip to content

Commit 44efb11

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

File tree

3 files changed

+12
-22
lines changed

3 files changed

+12
-22
lines changed

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -301,6 +301,11 @@ public final class ReaderPresenter: NSObject, SplitViewDisplayable {
301301
case let .tag(slug):
302302
viewModel.selection = nil
303303
show(ReaderStreamViewController.controllerWithTagSlug(slug))
304+
case let .siteID(siteID, isFeed):
305+
viewModel.selection = nil
306+
// Show the stream view controller immediately
307+
// It will fetch the topic and show loading/error states as needed
308+
show(ReaderStreamViewController.controllerWithSiteID(NSNumber(value: siteID), isFeed: isFeed))
304309
}
305310
}
306311

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

Lines changed: 6 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -168,28 +168,12 @@ private extension RootViewPresenter {
168168
}
169169
}
170170

171-
/// - warning: This method performs the navigation asyncronously after
172-
/// fetching the information about the stream from the backend.
171+
/// Shows a Reader stream for the given site/feed ID.
172+
///
173+
/// The stream view controller is displayed immediately with a loading state.
174+
/// Topic information is fetched asynchronously in the background, and the UI
175+
/// updates when the fetch completes or fails.
173176
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-
})
177+
showReader(path: .siteID(siteID, isFeed: isFeed))
194178
}
195179
}

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 siteID(Int, isFeed: Bool)
1617
}
1718

1819
extension ReaderNavigationPath {

0 commit comments

Comments
 (0)