Skip to content

CMM-2536: Sort RS Drafts and Trashed by modified date - #23429

Merged
nbradbury merged 7 commits into
trunkfrom
issue/cmm-2536-sort-drafts-by-modified
Oct 21, 2026
Merged

nbradbury merged 7 commits into
trunkfrom
issue/cmm-2536-sort-drafts-by-modified

Conversation

@nbradbury

@nbradbury nbradbury commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

TL;DR

Fixes CMM-2536.

As discussed in our last walkthrough, this PR updates the new RS posts list to sorts Drafts and Trashed by modified date, so the most recently edited drafts and the most recently trashed posts come first. This behavior matches iOS, with the addition of "Modified:" and "Trashed:" in the date line for clarification.

Description

Details
  • PostRsListTab gains modifiedDateLabelResId. Drafts and Trashed set it, and its computed orderBy is MODIFIED for any tab with a label, DATE otherwise.
  • ContentItemMapper gains modifiedDateFormat. When it's set, the row date and the date-header grouping come from modifiedGmt, and the row date is wrapped in the label. Without that, the headers would fragment ("Last week", "Today", "Last week"). Pages don't pass it, so they're unchanged.
  • Search keeps sorting by date and shows the normal date, because results mix statuses and have no date headers.
  • iOS sorts drafts by modified date in both its legacy list and its rs list. It sorts Trash by date but shows the modified date on each row. iOS has no date headers, while Android does, so here Trashed sorts by modified date too and the headers stay consistent with the rows.
  • Sorting by date alone was unreliable for drafts. WordPress core bumps post_date on each save for drafts with a floating date, but the app sends an explicit date on save, which pins it. So drafts last saved on the web moved to the top and drafts last saved in the app didn't.

Testing instructions

Drafts:

  1. Open Posts → Drafts on a site with several drafts.
  • Rows read "Modified: …", newest first, under matching date headers.
  1. Edit an older draft, save, and go back.
  • It's first, under "Today".

Trashed:

  1. Trash an older published post, then open Trashed.
  • It's first, under "Today", labelled "Trashed: Now".

Unchanged:

  • Published and Scheduled show the same order and dates as before.
  • Searching from Drafts shows the publish/creation date, with no "Modified" label.

Matches iOS. Draft rows show and group by the modified date so the date
headers stay contiguous. Search keeps sorting by date.
Lists the most recently trashed posts first, labelled "Trashed: <date>",
with the date headers following the same date.
@nbradbury nbradbury changed the title CMM-2536: Sort rs Drafts and Trashed by modified date CMM-2536: Sort RS Drafts and Trashed by modified date Oct 20, 2026
Derive the tab's sort from its date label so the two can't disagree, and
let the mapper apply the label instead of patching the date afterwards.
@wpmobilebot

wpmobilebot commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

App Icon📲 You can test the changes from this Pull Request in Jetpack Android by scanning the QR code below to install the corresponding build.

App NameJetpack Android
Build TypeDebug
Versionpr23429-b8f56d4
Build Number1498
Application IDcom.jetpack.android.prealpha
Commitb8f56d4
Installation URL6p79l63fh9gso
Automatticians: You can use our internal self-serve MC tool to give yourself access to those builds if needed.

@wpmobilebot

wpmobilebot commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

App Icon📲 You can test the changes from this Pull Request in WordPress Android by scanning the QR code below to install the corresponding build.

App NameWordPress Android
Build TypeDebug
Versionpr23429-b8f56d4
Build Number1498
Application IDorg.wordpress.android.prealpha
Commitb8f56d4
Installation URL4o2v1qd9humb8
Automatticians: You can use our internal self-serve MC tool to give yourself access to those builds if needed.

@wpmobilebot

This comment was marked as resolved.

@codecov

codecov Bot commented Oct 20, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 53.57143% with 13 lines in your changes missing coverage. Please review.
✅ Project coverage is 39.07%. Comparing base (15dbd27) to head (b8f56d4).

Files with missing lines Patch % Lines
...ordpress/android/ui/postsrs/PostRsListViewModel.kt 0.00% 10 Missing ⚠️
...ess/android/ui/rs/contentlist/ContentItemMapper.kt 72.72% 2 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##            trunk   #23429      +/-   ##
==========================================
- Coverage   39.07%   39.07%   -0.01%     
==========================================
  Files        2304     2304              
  Lines      128911   128926      +15     
  Branches    18301    18307       +6     
==========================================
+ Hits        50373    50378       +5     
- Misses      74301    74310       +9     
- Partials     4237     4238       +1     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@nbradbury
nbradbury marked this pull request as ready for review October 21, 2026 11:19
@adalpari

Copy link
Copy Markdown
Contributor

Looks good and works as expected.

Just noting these small sugestions:

# Severity Location Issue Impact
1 🟡 Medium PostRsListViewModel.kt:867 Switching Drafts/Trashed to orderby=modified changes the rs list cache key, so both tabs start from a cold key after the update. orderby is part of the key (wp_mobile/src/cache_key.rs:65, post_list_filter_cache_key); the old orderby=date list row stays behind orphaned. User with cached drafts updates the app, goes offline, opens Posts → Published renders from cache, swipes to Drafts → loadItems() returns 0 → refreshTab fails offline → onRefreshFailed with items.isEmpty() renders the full-screen "no connection" + Retry where their drafts used to be. One-time per tab; recovers on the next online refresh. Online it costs one forced shimmer + round trip per tab.
2 🔵 Low ContentItemMapper.kt:66 For Stale / FetchingWithData / FailedWithData rows the position comes from freshly-refreshed list metadata (ordered by server modified) while date and dateGmtMillis come from the older cached entity, so the row's date can contradict its own position. Before this PR dateGmt was effectively immutable, so the two could not drift. Draft edited on the web; app refreshes Drafts → the row takes its new top position but still shows the cached "Modified: 3 days ago", and buildEntries (PostRsTabListScreen.kt:239) opens a "Last month" header between "Today" rows. Clears when the stale entity fetch lands; permanent while the row is FailedWithData.
3 🔵 Low ContentListRow.kt:368 In RowMetaLine the date is an unweighted MetaText measured before the author, which only gets the remainder, so the ~10-char "Modified: " / "Trashed: " prefix is taken out of the author's space on every Drafts/Trashed row (longer translated: de "Geändert: ", es "Modificado: "). Multi-author site, author filter = Everyone, condensed density with a thumbnail (~216dp text column) and an absolute date: the author name goes from ~19 visible characters to ~10; at font scale ≥1.3 it disappears. Same at comfortable density on Trashed (no footer, ~282dp) at large font scale. Degrades the way the file's own KDoc describes, so arguably intended.

@nbradbury

Copy link
Copy Markdown
Contributor Author

@adalpari Thanks! All three check out.

  1. Accepting this one: it’s one-time per tab, offline only, and the same as toggling the author filter offline today, since author is part of the key too.
  2. Good catch. wordpress-rs already has modified_gmt in EntityMetadata but doesn’t expose it on PostMetadataCollectionItem. I’ll open a wordpress-rs issue to add it.
  3. Leaving as is: it’s the row’s intended way of giving up space, and dropping the prefix would undo the label.

@nbradbury
nbradbury merged commit c75b331 into trunk Oct 21, 2026
26 of 30 checks passed
@nbradbury
nbradbury deleted the issue/cmm-2536-sort-drafts-by-modified branch October 21, 2026 13:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants