diff --git a/Frameworks/Account/FeedProvider/Reddit/RedditFeedProvider.swift b/Frameworks/Account/FeedProvider/Reddit/RedditFeedProvider.swift index 9886f95bb..1ebebbd73 100644 --- a/Frameworks/Account/FeedProvider/Reddit/RedditFeedProvider.swift +++ b/Frameworks/Account/FeedProvider/Reddit/RedditFeedProvider.swift @@ -227,7 +227,7 @@ public final class RedditFeedProvider: FeedProvider { } } - public static func buildURL(_ type: RedditFeedType, username: String?, subreddit: String?) -> URL? { + public static func buildURL(_ type: RedditFeedType, username: String?, subreddit: String?, sort: RedditSort) -> URL? { var components = URLComponents() components.scheme = "https" components.host = "www.reddit.com" @@ -238,23 +238,24 @@ public final class RedditFeedProvider: FeedProvider { return nil } components.user = username + components.path = "/\(sort.rawValue)" case .popular: guard let username = username else { return nil } components.user = username - components.path = "/r/popular" + components.path = "/r/popular/\(sort.rawValue)" case .all: guard let username = username else { return nil } components.user = username - components.path = "/r/all" + components.path = "/r/all/\(sort.rawValue)" case .subreddit: guard let subreddit = subreddit else { return nil } - components.path = "/r/\(subreddit)" + components.path = "/r/\(subreddit)/\(sort.rawValue)" } return components.url diff --git a/Frameworks/Account/FeedProvider/Reddit/RedditSort.swift b/Frameworks/Account/FeedProvider/Reddit/RedditSort.swift index 345443323..047fcd253 100644 --- a/Frameworks/Account/FeedProvider/Reddit/RedditSort.swift +++ b/Frameworks/Account/FeedProvider/Reddit/RedditSort.swift @@ -8,7 +8,7 @@ import Foundation -enum RedditSort: String, CaseIterable { +public enum RedditSort: String, CaseIterable { case best case rising case hot diff --git a/Mac/Base.lproj/AddRedditFeedSheet.xib b/Mac/Base.lproj/AddRedditFeedSheet.xib index cdffd1ec3..490be1abf 100644 --- a/Mac/Base.lproj/AddRedditFeedSheet.xib +++ b/Mac/Base.lproj/AddRedditFeedSheet.xib @@ -12,6 +12,7 @@ + @@ -23,10 +24,10 @@ - + - + - + @@ -64,7 +65,7 @@ DQ - + @@ -82,7 +83,7 @@ DQ - + @@ -90,7 +91,7 @@ DQ - + @@ -102,7 +103,7 @@ DQ - + @@ -112,16 +113,32 @@ DQ + + + + + + + + + + + + + + + + - + - + - + @@ -129,7 +146,7 @@ DQ - + @@ -137,7 +154,7 @@ DQ - + @@ -145,7 +162,7 @@ DQ - + @@ -158,9 +175,18 @@ DQ + + + + + + + + + @@ -169,8 +195,10 @@ DQ + + @@ -178,7 +206,7 @@ DQ - + @@ -190,10 +218,28 @@ DQ + + - + + + + + + + + + + + + + + + + + diff --git a/Mac/MainWindow/AddRedditFeedWindowController.swift b/Mac/MainWindow/AddRedditFeedWindowController.swift index bab6760e2..0e0b36a52 100644 --- a/Mac/MainWindow/AddRedditFeedWindowController.swift +++ b/Mac/MainWindow/AddRedditFeedWindowController.swift @@ -21,6 +21,8 @@ class AddRedditFeedWindowController : NSWindowController, AddFeedWindowControlle @IBOutlet weak var accountPopupButton: NSPopUpButton! @IBOutlet weak var subredditTextField: NSTextField! + @IBOutlet weak var sortPopupButton: NSPopUpButton! + @IBOutlet var nameTextField: NSTextField! @IBOutlet var addButton: NSButton! @IBOutlet var folderPopupButton: NSPopUpButton! @@ -28,6 +30,21 @@ class AddRedditFeedWindowController : NSWindowController, AddFeedWindowControlle private weak var delegate: AddFeedWindowControllerDelegate? private var folderTreeController: TreeController! + private var userSelectedSort: RedditSort { + switch sortPopupButton.selectedItem?.tag ?? 0 { + case 0: + return .best + case 1: + return .hot + case 2: + return .new + case 3: + return .top + default: + return .rising + } + } + private var userEnteredSubreddit: String? { var s = subredditTextField.stringValue s = s.collapsingWhitespace @@ -102,7 +119,7 @@ class AddRedditFeedWindowController : NSWindowController, AddFeedWindowControlle let atUsername = accountPopupButton.selectedItem?.title else { return } let username = String(atUsername[atUsername.index(atUsername.startIndex, offsetBy: 2)..