-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Reader: Local Default Topics #23788
base: trunk
Are you sure you want to change the base?
Reader: Local Default Topics #23788
Conversation
📲 You can test the changes from this Pull Request in WordPress Alpha by scanning the QR code below to install the corresponding build.
|
📲 You can test the changes from this Pull Request in Jetpack Alpha by scanning the QR code below to install the corresponding build.
|
114123d
to
2c1d3ac
Compare
let topic = ReaderDefaultTopic(entity: ReaderDefaultTopic.entity(), insertInto: context) | ||
topic.type = TopicType | ||
topic.path = path.rawValue | ||
topic.title = "" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a required field but it's never used only by other topic types.
@@ -10,9 +10,6 @@ | |||
@import WordPressKit; | |||
@import WordPressShared; | |||
|
|||
NSString * const ReaderTopicFreshlyPressedPathCommponent = @"freshly-pressed"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No longer used.
if ReaderHelpers.isTopicTag(topic) { | ||
return true | ||
} | ||
return (topic is ReaderDefaultTopic) && !ReaderHelpers.topicIsLiked(topic) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There has to be a better way to do it, but I'm not refactoring it in the scope of this PR.
@@ -214,11 +214,6 @@ import AutomatticTracks | |||
/// - Returns: An instance of the controller | |||
/// | |||
@objc class func controllerWithTopic(_ topic: ReaderAbstractTopic) -> ReaderStreamViewController { | |||
// if a default discover topic is provided, treat it as a site to retrieve the header | |||
if ReaderHelpers.topicIsDiscover(topic) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think we need this anymore. The worst case scenario, it'll just open as a regular site feed.
Is this a breakpoint in Xcode, or do you mean intercepting the HTTP request from HTTP proxy apps? |
case recommended = "/jpios/discover/recommended" | ||
case firstPosts = "/jpios/discover/first-posts" | ||
case latest = "/jpios/discover/latest" | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does it mean there should be three unique "default topics" (a.k.a "Discover" topics?) in Core Data? If that's the case, should we delete -[ReaderTopicService defaultTopicForRemoteTopic:inContext:]
to avoid arbitrary ReaderDefaultTopic
being created?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are two that are still remaining: one for "Recent" and one for "Likes", so I can't remove them just yet. The "Discover" topic will also be in the database for now, but the app never displays them anywhere, so it's going to be fine. My plan is to ultimately remove ReaderDefaultTopic
entirely. There are no good reasons to store them in Core Data.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Btw, this PR also fixes the following issue:
Steps
- Open Discover
- Select "Latest Posts" and wait until they load
- Terminate the app
- Reopen Discover (it shows "Recommended" again)
Expected result:
- It loads new posts
Actual result:
- It shows posts cached for "Latest Posts", then reloads
topic.type = TopicType | ||
topic.path = path.rawValue | ||
topic.title = "" | ||
try context.save() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should use performAndSave
instead of saving the context directly. Or, at bare minimal, use ContextManager.save
.
Also, we don't update and save the main context.
78e1ff7
to
45c09af
Compare
45c09af
to
6f712d3
Compare
I don't feel comfortable merging this late in the game, so I'm moving it to draft. |
Version |
Version |
Background
When you open the Reader, it fetches
/read/menu
that contains the following fields:For each of these menu items, the app creates a
ReaderDefaultTopic
instance of Core Data. The main role of these topics is to be used in predicates for caching posts:NSPredicate(format: "topic = %@)
.There are two main issue with this approach:
/read/menu
read/sites/53424024/posts
) for Discover. If the path ever changes on the backend, Discover will completely stop working in the app.With Discover, the app uses neither the
URL
nor thetitle
field from the response, so it's a pretty easy update to no longer rely on this value. This is not the case for "Followed Sites" and "My Likes" where the app actually uses thepath
in multiple ways, including for fetching the respective feeds.Changes
ReaderDefaultTopic
for "Discover" locallycurrentTopic
(no longer used)ReaderTopicType
(not needed anymore)To test:
/read/menu
Future Changes
/read/menu
. This is a larger change and I decided not to make it in the scope of this PR.Regression Notes
Potential unintended areas of impact
What I did to test those areas of impact (or what existing automated tests I relied on)
What automated tests I added (or what prevented me from doing so)
PR submission checklist:
RELEASE-NOTES.txt
if necessary.Testing checklist: