feat(mangas): per-field sort options + direction toggle on the catalog (0.88.0)
Replace the two-option `ListSort` enum with an orthogonal sort field (created/updated/title/author, default updated) and direction (asc/desc, default desc). The catalog now defaults to last-updated-first and lets the user order by any field in either direction. Backend builds ORDER BY from the enums only (no injection seam), with a NULLS-LAST author subquery and a stable id tie-break. Frontend adds a direction toggle with per-field defaults (dates desc, text asc) and labels (Newest/Oldest vs A->Z/Z->A), reusing SegmentedControl; URL state omits the per-field defaults and validates on hydrate. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -52,7 +52,9 @@ pub struct ListParams {
|
||||
#[serde(default)]
|
||||
pub offset: i64,
|
||||
#[serde(default)]
|
||||
pub sort: repo::manga::ListSort,
|
||||
pub sort: repo::manga::SortField,
|
||||
#[serde(default)]
|
||||
pub order: repo::manga::SortOrder,
|
||||
}
|
||||
|
||||
fn default_limit() -> i64 {
|
||||
@@ -105,6 +107,7 @@ async fn list(
|
||||
limit,
|
||||
offset,
|
||||
sort: params.sort,
|
||||
order: params.order,
|
||||
};
|
||||
let (items, total) = repo::manga::list_cards(&state.db, &q).await?;
|
||||
Ok(Json(PagedResponse::with_total(items, limit, offset, total)))
|
||||
|
||||
Reference in New Issue
Block a user