feat(playlist): restore the "Date added" sort option

2.0 dropped the v1.x "added" sort. Restore it with the same semantics:
a positional proxy over the playlist's natural insertion order (the API
returns tracks oldest-first; no added-at timestamp is deserialized),
starting newest-first on first selection, re-click toggles direction.
New msgid translated in all 7 locales.

Fixes #546

cc
This commit is contained in:
vicrodh committed 2026-07-05 08:04:07 -06:00
1 parent bd2c1a6c21
commit de5c50a5b3
9 files changed
+43 -1

No files matched your search

@@ -4355,3 +4355,6 @@ msgstr "DoP — DSD über PCM (bit-perfekt)"
msgid "Native DSD (kernel support required)" msgid "Native DSD (kernel support required)"
msgstr "Natives DSD (Kernel-Unterstützung erforderlich)" msgstr "Natives DSD (Kernel-Unterstützung erforderlich)"
msgid "Date added"
msgstr "Hinzugefügt am"
@@ -94,3 +94,6 @@ msgstr "Signing you in…"
msgid "Sign-in failed" msgid "Sign-in failed"
msgstr "Sign-in failed" msgstr "Sign-in failed"
msgid "Date added"
msgstr "Date added"
@@ -4385,3 +4385,6 @@ msgstr "DoP — DSD sobre PCM (bit-perfect)"
msgid "Native DSD (kernel support required)" msgid "Native DSD (kernel support required)"
msgstr "DSD nativo (requiere soporte del kernel)" msgstr "DSD nativo (requiere soporte del kernel)"
msgid "Date added"
msgstr "Fecha de agregado"
@@ -4355,3 +4355,6 @@ msgstr "DoP — DSD sur PCM (bit-perfect)"
msgid "Native DSD (kernel support required)" msgid "Native DSD (kernel support required)"
msgstr "DSD natif (prise en charge du noyau requise)" msgstr "DSD natif (prise en charge du noyau requise)"
msgid "Date added"
msgstr "Date d'ajout"
@@ -4344,3 +4344,6 @@ msgstr "DoP — PCM上のDSD(ビットパーフェクト)"
msgid "Native DSD (kernel support required)" msgid "Native DSD (kernel support required)"
msgstr "ネイティブDSD(カーネルサポートが必要)" msgstr "ネイティブDSD(カーネルサポートが必要)"
msgid "Date added"
msgstr "追加日"
@@ -4355,3 +4355,6 @@ msgstr "DoP — DSD sobre PCM (bit-perfect)"
msgid "Native DSD (kernel support required)" msgid "Native DSD (kernel support required)"
msgstr "DSD nativo (requer suporte do kernel)" msgstr "DSD nativo (requer suporte do kernel)"
msgid "Date added"
msgstr "Data de adição"
@@ -4368,3 +4368,6 @@ msgstr "DoP — DSD поверх PCM (бит-перфект)"
msgid "Native DSD (kernel support required)" msgid "Native DSD (kernel support required)"
msgstr "Нативный DSD (требуется поддержка ядра)" msgstr "Нативный DSD (требуется поддержка ядра)"
msgid "Date added"
msgstr "Дата добавления"
@@ -333,6 +333,7 @@ export component PlaylistView inherits Rectangle {
: PlaylistState.sort-field == "artist" ? @tr("Artist") : PlaylistState.sort-field == "artist" ? @tr("Artist")
: PlaylistState.sort-field == "album" ? @tr("Album") : PlaylistState.sort-field == "album" ? @tr("Album")
: PlaylistState.sort-field == "duration" ? @tr("Duration") : PlaylistState.sort-field == "duration" ? @tr("Duration")
: PlaylistState.sort-field == "added" ? @tr("Date added")
: PlaylistState.sort-field == "custom" ? @tr("Custom") : PlaylistState.sort-field == "custom" ? @tr("Custom")
: @tr("Default"); : @tr("Default");
@@ -801,6 +802,16 @@ export component PlaylistView inherits Rectangle {
asc: PlaylistState.sort-asc; asc: PlaylistState.sort-asc;
chosen => { PlaylistActions.set-sort("duration"); } chosen => { PlaylistActions.set-sort("duration"); }
} }
// Positional proxy for when each
// track entered the playlist (the
// API returns insertion order) —
// v1.x parity, starts newest-first.
SortOption {
label: @tr("Date added");
active: PlaylistState.sort-field == "added";
asc: PlaylistState.sort-asc;
chosen => { PlaylistActions.set-sort("added"); }
}
// Manual order — enables the per-row // Manual order — enables the per-row
// up/down reorder controls. Hidden on // up/down reorder controls. Hidden on
// LOCAL playlists (B2): their Default // LOCAL playlists (B2): their Default
+11 -1
View File
@@ -106,6 +106,14 @@ fn refresh_view(window: &AppWindow) {
.and_then(|k| order.get(&k).copied()) .and_then(|k| order.get(&k).copied())
.unwrap_or(i32::MAX) .unwrap_or(i32::MAX)
}); });
} else if field == "added" {
// "Date added" is a positional proxy (v1.x parity): FULL_ITEMS is in
// the playlist's natural insertion order (the API returns tracks
// oldest-first) and the filter above preserves it, so asc = oldest
// first and desc = newest first is a plain reversal.
if !asc {
view.reverse();
}
} else if field != "default" { } else if field != "default" {
view.sort_by(|a, b| { view.sort_by(|a, b| {
let ord = match field.as_str() { let ord = match field.as_str() {
@@ -171,7 +179,9 @@ pub fn set_sort(window: &AppWindow, field: &str) {
} else if cur.0 == field { } else if cur.0 == field {
cur.1 = !cur.1; cur.1 = !cur.1;
} else { } else {
*cur = (field.to_string(), true); // "added" starts newest-first (desc) — v1.x parity; the other
// fields start ascending.
*cur = (field.to_string(), field != "added");
} }
}); });
let (field, asc) = SORT.with(|s| s.borrow().clone()); let (field, asc) = SORT.with(|s| s.borrow().clone());