Skip to content

feat: sort content by date added or recently updated - #1080

Open
tunaseckin wants to merge 2 commits into
Polyfrost:mainfrom
tunaseckin:feat/sort-content-by-date
Open

tunaseckin wants to merge 2 commits into
Polyfrost:mainfrom
tunaseckin:feat/sort-content-by-date

Conversation

@tunaseckin

Copy link
Copy Markdown
Contributor

Two people asked for this in #suggestions on Discord ("Mods ordered in when added" and "sort mods by update date"). The content list could only sort by name or size, so this adds two options to the sort menu:

  • Recently Added: newest files in the instance first
  • Recently Updated: sorted by when the installed version was released, newest first

Rows with no date go to the bottom, with name as the tie-break.

The release date was already loaded (published_at). The date added wasn't stored for anything a user installed, because installed_at only covers bundle files and gets cleared when a bundle drops one. So there's a migration that adds cluster_artifacts.added_at, copies over the installed_at values that exist, and adds an insert trigger that stamps new rows. I used a trigger instead of setting it in each insert because SQLite won't take a non-constant default on ALTER TABLE, and it covers every path that links a file, including the shared-folder copies. Relinking the same file goes through the upsert, so it keeps its original date. A new version of a mod is a new row, so updating a mod counts as adding it.

Files installed before this have no date, so they sit at the bottom of Recently Added until they're reinstalled or updated.

.sqlx is regenerated for the changed list_cluster_artifacts_detailed query. I checked the trigger against a migrated database (new rows get a time, upserts keep theirs, explicit values aren't touched) and added a test for the sort order. Workspace tests pass.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

1 participant