Skip to content

fix: sort recent files newest first - #85

Merged
moodyjmz merged 2 commits into
mainfrom
fix/sort-recent-files-newest-first
Jul 23, 2026
Merged

fix: sort recent files newest first#85
moodyjmz merged 2 commits into
mainfrom
fix/sort-recent-files-newest-first

Conversation

@moodyjmz

Copy link
Copy Markdown
Contributor

Summary

Replaces #79, rebased onto current main and with tests applied — the file-filtering logic #79 targeted has since moved from OfficeOverview.vue to src/utils/fileFilters.ts (refactor: extract file-filtering logic to utils), so #79 as written no longer touches the live code path.

  • sortNodes() from @nextcloud/files inverts sortingOrder for sortingMode: 'mtime' ('asc' = newest first). main passed 'desc', so the Recent list rendered oldest-first.
  • Bigger than cosmetic: OfficeOverview.vue caps the rendered list at MAX_DISPLAY_FILES (200) after sorting. Anyone with more than 200 matching files was seeing the 200 oldest, with the actual newest files hidden entirely behind "Show all in Files".
  • Fixes src/utils/fileFilters.ts, updates the existing sort-order spec, and adds a regression test pinning that the 200-file cap keeps the newest files, not the oldest (previously untested — a revert to 'desc' would have passed CI green).

Diagnosis and the original one-line fix are Frank Karlitschek's (#79) — credited via Co-authored-by: on the commit. This PR is that fix carried forward onto current main with the target file corrected and tests added.

Test plan

  • npm run test:unit — 70/70 passing (Node 24; Node 25 has an unrelated known localStorage/jsdom issue, see README)
  • New regression test: OfficeOverview > MAX_DISPLAY_FILES cap > keeps the newest files, not the oldest

sortNodes() from @nextcloud/files inverts the sorting order when
sortingMode is 'mtime' ('asc' means most recently modified first).
Passing 'desc' therefore showed the oldest documents at the top of
the Recent list — and since OfficeOverview caps the rendered list at
MAX_DISPLAY_FILES (200), users with more matching files than that saw
the 200 oldest, with the newest hidden behind "Show all in Files"
entirely. Pass 'asc' and document the inversion.

Adds a regression test pinning that the cap keeps the newest files,
not the oldest, plus updates the existing sort-order spec.

Diagnosis and original fix by Frank Karlitschek (#79); rebased here
onto current main (the file-filtering logic has since moved to
src/utils/fileFilters.ts) with the accompanying tests applied.

Co-authored-by: Frank Karlitschek <karlitschek@users.noreply.github.com>
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Signed-off-by: James Manuel <moodyjmz@users.noreply.github.com>
@moodyjmz

Copy link
Copy Markdown
Contributor Author

@karlitschek I did a new PR here from the newer main - has tests extracted

@moodyjmz moodyjmz mentioned this pull request Jul 23, 2026
1 task
@moodyjmz

Copy link
Copy Markdown
Contributor Author

/compile

Signed-off-by: nextcloud-command <nextcloud-command@users.noreply.github.com>
@moodyjmz
moodyjmz merged commit db5d921 into main Jul 23, 2026
25 checks passed
@moodyjmz
moodyjmz deleted the fix/sort-recent-files-newest-first branch July 23, 2026 14:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants