Skip to content
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ public enum ReaderSortingOption: String, CaseIterable {

public enum ReaderStream: String {
case discover = "discover"
case freshlyPressed = "freshly-pressed"
case firstPosts = "first-posts"
}

Expand Down
9 changes: 8 additions & 1 deletion Modules/Sources/WordPressKitObjC/RemoteReaderPost.m
Original file line number Diff line number Diff line change
Expand Up @@ -507,7 +507,14 @@ - (NSString *)featuredImageFromPostDictionary:(NSDictionary *)dict
}

- (NSString *)editorialImageFromPostDictionary:(NSDictionary *)dict {
return [dict stringForKeyPath:@"editorial.image"];
NSString *imageURL = [dict stringForKeyPath:@"editorial.image"];
// A workaround for https://linear.app/a8c/issue/CMM-994/reader-invalid-featured-images-for-posts-in-freshly-pressed-feed
// The app does not support `mshots` images. We also never want to show
// screenshots of posts as featured images, so it's safe to skip these.
if ([imageURL containsString:@"wp.com/mshots/"]) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I figured we can opt-out of these on the app side as we never want mshots to be used from the app.

return nil;
}
return imageURL;
}

- (NSString *)userSpecifiedFeaturedImageFromPostDictionary:(NSDictionary *)dict {
Expand Down
2 changes: 1 addition & 1 deletion RELEASE-NOTES.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
26.6
-----

* [**] Add "Freshly Pressed" to Discover in Reader [#24828]

26.5
-----
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import WordPressShared

class ReaderDiscoverViewController: UIViewController, ReaderDiscoverHeaderViewDelegate {
private let headerView = ReaderDiscoverHeaderView()
private var selectedChannel: ReaderDiscoverChannel = .recommended
private var selectedChannel: ReaderDiscoverChannel = .freshlyPresed
private let topic: ReaderAbstractTopic
private var streamVC: ReaderStreamViewController?
private weak var selectInterestsVC: ReaderSelectInterestsViewController?
Expand Down Expand Up @@ -83,7 +83,7 @@ class ReaderDiscoverViewController: UIViewController, ReaderDiscoverHeaderViewDe
.filter { $0.slug != ReaderTagTopic.dailyPromptTag }
.map(ReaderDiscoverChannel.tag)

headerView.configure(channels: [.recommended, .firstPosts, .latest, .dailyPrompts] + channels)
headerView.configure(channels: [.freshlyPresed, .recommended, .firstPosts, .latest, .dailyPrompts] + channels)
headerView.setSelectedChannel(selectedChannel)
}

Expand All @@ -95,6 +95,8 @@ class ReaderDiscoverViewController: UIViewController, ReaderDiscoverHeaderViewDe

private func makeViewController(for channel: ReaderDiscoverChannel) -> ReaderStreamViewController {
switch channel {
case .freshlyPresed:
ReaderStreamViewController.controllerWithTopic(ReaderHelpers.getFreshlyPressedTopic())
case .recommended:
ReaderDiscoverStreamViewController(topic: topic)
case .firstPosts:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,18 @@
return topic.path.hasSuffix("/freshly-pressed")
}

public static func getFreshlyPressedTopic(in context: NSManagedObjectContext = ContextManager.shared.mainContext) -> ReaderSiteTopic {
let path = "/rest/v1.2/freshly-pressed"

Check warning on line 122 in WordPress/Classes/ViewRelated/Reader/Controllers/ReaderHelpers.swift

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Refactor your code to get this URI from a customizable parameter.

See more on https://sonarcloud.io/project/issues?id=wordpress-mobile_WordPress-iOS&issues=AZq7Jrcr09Rot4Ve0zWk&open=AZq7Jrcr09Rot4Ve0zWk&pullRequest=24828
if let topic = try? ReaderSiteTopic.lookup(withFeedURL: path, in: context) {
return topic
}
let topic = context.insertNewObject(ofType: ReaderSiteTopic.self)
topic.feedURL = path
topic.path = path
try? context.save()
return topic
}

/// Check if the specified topic is for Discover
///
/// - Parameters:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,9 @@
}

enum ReaderDiscoverChannel: Hashable {
/// Curated posts.
case freshlyPresed

/// The default channel showing your selected tags.
case recommended

Expand All @@ -207,6 +210,8 @@

var localizedTitle: String {
switch self {
case .freshlyPresed:
NSLocalizedString("reader.discover.channel.freshlyPresed", value: "Freshly Pressed", comment: "Header view channel (filter)")

Check failure on line 214 in WordPress/Classes/ViewRelated/Reader/Headers/ReaderDiscoverHeaderView.swift

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Define a constant instead of duplicating this literal 5 times.

See more on https://sonarcloud.io/project/issues?id=wordpress-mobile_WordPress-iOS&issues=AZq7Jrg809Rot4Ve0zWl&open=AZq7Jrg809Rot4Ve0zWl&pullRequest=24828
case .recommended:
NSLocalizedString("reader.discover.channel.recommended", value: "Recommended", comment: "Header view channel (filter)")
case .firstPosts:
Expand All @@ -230,6 +235,7 @@

private var analyticsID: String {
switch self {
case .freshlyPresed: "freshly_presed"
case .recommended: "recommended"
case .firstPosts: "first_posts"
case .latest: "latest"
Expand Down