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
12 changes: 9 additions & 3 deletions podcasts/AppDelegate+UrlHandling.swift
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,13 @@ extension AppDelegate {

// Support for subscribing to a feed URL
JLRoutes.global().addRoute("/subscribe/*") { [weak self] parameters -> Bool in
guard let strongSelf = self, let controller = SceneHelper.rootViewController(), let subscribeUrl = (parameters[JLRouteURLKey] as? URL)?.absoluteString else { return false }
guard
let strongSelf = self,
let rootController = SceneHelper.rootViewController(includeTopMost: false), //I don't want to consider the top most presented but the main root instead
let subscribeUrl = (parameters[JLRouteURLKey] as? URL)?.absoluteString
else {
return false
}

let prefix = "pktc://subscribe/"
if prefix.count >= subscribeUrl.count { return true } // this request is missing a URL
Expand All @@ -179,8 +185,8 @@ extension AppDelegate {
let searchTerm = !feedUrl.hasPrefix("http://") && !feedUrl.hasPrefix("https://") ? "http://\(feedUrl)" : feedUrl

strongSelf.progressDialog = ShiftyLoadingAlert(title: L10n.podcastLoading)
controller.dismiss(animated: false, completion: nil)
strongSelf.progressDialog?.showAlert(controller, hasProgress: false, completion: {
rootController.dismiss(animated: false, completion: nil)
strongSelf.progressDialog?.showAlert(rootController, hasProgress: false, completion: {
MainServerHandler.shared.podcastSearch(searchTerm: searchTerm) { response in
guard let uuid = response?.result?.podcast?.uuid else {
DispatchQueue.main.async {
Expand Down
7 changes: 5 additions & 2 deletions podcasts/SceneHelper.swift
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,13 @@ class SceneHelper {
return UIWindow(frame: UIScreen.main.bounds)
}

class func rootViewController() -> UIViewController? {
class func rootViewController(includeTopMost: Bool = true) -> UIViewController? {
let appScene = connectedScene()?.windows.first(where: { $0.rootViewController is MainTabBarController })
let rootVC = appScene?.rootViewController
return rootVC?.topMostPresentedViewController ?? rootVC
if includeTopMost {
return rootVC?.topMostPresentedViewController ?? rootVC
}
return rootVC
}

/// Returns the main window for the app from the AppDelegate
Expand Down