Skip to content

Commit f4db242

Browse files
nbradburyclaude
andauthored
Reader: Preserve editorial date on post detail refresh (#22783)
* Reader: Preserve editorial date when detail endpoint refreshes post When the Reader detail screen fetches a post, the response lacks the editorial section, causing the raw date field to overwrite the correct Freshly Pressed displayed_on date. Preserve the existing date_published from the DB before saving. Co-Authored-By: Claude Opus 4.6 <[email protected]> * Reader: Remove redundant isEmpty check on preserved date getDatePublished() already returns a non-null string via StringUtils.notNullStr(), making the TextUtils.isEmpty guard unnecessary. Co-Authored-By: Claude Opus 4.6 <[email protected]> --------- Co-authored-by: Claude Opus 4.6 <[email protected]>
1 parent cf81ab8 commit f4db242

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

WordPress/src/main/java/org/wordpress/android/ui/reader/actions/ReaderPostActions.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -293,6 +293,19 @@ public void onResponse(JSONObject jsonObject) {
293293
new Thread(() -> {
294294
ReaderPost post = ReaderPost.fromJson(jsonObject);
295295

296+
// Preserve the existing date_published if the post
297+
// already exists in the DB. This prevents editorial
298+
// dates (e.g. Freshly Pressed "displayed_on") from
299+
// being overwritten when the detail endpoint response
300+
// lacks the editorial section.
301+
ReaderPost existingPost =
302+
ReaderPostTable.getBlogPost(
303+
post.blogId, post.postId, true);
304+
if (existingPost != null) {
305+
post.setDatePublished(
306+
existingPost.getDatePublished());
307+
}
308+
296309
ReaderPostTable.addPost(post);
297310
handlePostLikes(post, jsonObject);
298311

0 commit comments

Comments
 (0)