Skip to content

Commit 9475a67

Browse files
fix(settings): add missing keybinding rows (#927)
# Summary <!-- What does this PR change and why? Keep it short. --> Add Settings rows for Jump to Start, Jump to End and Listening Party. Fixes #828. # Testing <!-- List the commands you ran yourself and their output. For a good first issue, run every command under "Done when". Example: - cargo fmt --all - cargo clippy --no-default-features --features telemetry,tui -- -D warnings - cargo test --no-default-features --features telemetry,tui - cargo test (when you changed code behind a feature flag) --> - `cargo fmt --all` - `cargo test --features gui` # Additional notes <!-- Screenshots for UI changes, breaking change callouts, or follow-up work. --> --- <sub>💬 Questions or want to chat with other contributors? Join the [spotatui Discord](https://spotatui.com/discord).</sub> <!-- This is an auto-generated comment: release notes by coderabbit.ai --> <!-- coderabbit-ai-generated:v1 --> ## Summary by CodeRabbit * **New Features** * Jump to Start, Jump to End, and Listening Party can now be assigned custom shortcuts in Settings > Keybindings. * Jump to Start and Jump to End move to the first and last rows of a list, respectively. The Listening Party shortcut opens its menu and is available when a Spotify session is active. <!-- end of auto-generated comment: release notes by coderabbit.ai --> Co-authored-by: LargeModGames <84450916+LargeModGames@users.noreply.github.com>
1 parent 95a123b commit 9475a67

7 files changed

Lines changed: 130 additions & 1 deletion

File tree

‎CHANGELOG.md‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,8 @@
4343

4444
- **Saved Albums goes back to newest saved first on Default**: picking Default in the sort menu after another sort left the list in that order until the next refetch, because Default had no case in the sort. It now orders each page by when the album was saved, newest first, whatever the previous order was ([#817](https://github.com/LargeModGames/spotatui/issues/817)).
4545

46+
- **Jump and Listening Party keys can be rebound in Settings**: the Keybindings tab now includes Jump to Start, Jump to End and Listening Party ([#828](https://github.com/LargeModGames/spotatui/issues/828)).
47+
4648
- **`playback --repeat` now advances repeat modes** from Off to Context to Track instead of sending the current mode ([#816](https://github.com/LargeModGames/spotatui/issues/816)).
4749

4850
- **Apple Music playlists show their real song counts** in the desktop app and the browser GUI: every playlist in Your Library, "All songs" included, said `0 songs`, because the count was never read from Music. It now is, one playlist at a time, which adds about 8 ms per playlist to loading the sidebar; a playlist whose count Music cannot read shows no number rather than a wrong 0 ([#891](https://github.com/LargeModGames/spotatui/issues/891)).

‎gui/src/bindings/SettingsStrings.ts‎

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

‎gui/src/bindings/strings.json‎

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1354,8 +1354,14 @@
13541354
"keys_jump_to_artist_album_name": "Jump to Artist",
13551355
"keys_jump_to_context_description": "Jump to current playback context",
13561356
"keys_jump_to_context_name": "Jump to Context",
1357+
"keys_jump_to_end_description": "Jump to the last row of the list",
1358+
"keys_jump_to_end_name": "Jump to End",
1359+
"keys_jump_to_start_description": "Jump to the first row of the list",
1360+
"keys_jump_to_start_name": "Jump to Start",
13571361
"keys_like_track_description": "Toggle saved state for the currently playing track or episode",
13581362
"keys_like_track_name": "Like Track",
1363+
"keys_listening_party_description": "Open the Listening Party menu",
1364+
"keys_listening_party_name": "Listening Party",
13591365
"keys_lyrics_view_description": "Open lyrics view",
13601366
"keys_lyrics_view_name": "Lyrics View",
13611367
"keys_manage_devices_description": "Open the source and device picker",
@@ -3359,8 +3365,14 @@
33593365
"keys_jump_to_artist_album_name": "前往艺人",
33603366
"keys_jump_to_context_description": "前往当前播放所属列表",
33613367
"keys_jump_to_context_name": "前往所属列表",
3368+
"keys_jump_to_end_description": "Jump to the last row of the list",
3369+
"keys_jump_to_end_name": "Jump to End",
3370+
"keys_jump_to_start_description": "Jump to the first row of the list",
3371+
"keys_jump_to_start_name": "Jump to Start",
33623372
"keys_like_track_description": "切换当前播放曲目或单集的收藏状态",
33633373
"keys_like_track_name": "喜欢曲目",
3374+
"keys_listening_party_description": "Open the Listening Party menu",
3375+
"keys_listening_party_name": "Listening Party",
33643376
"keys_lyrics_view_description": "打开歌词视图",
33653377
"keys_lyrics_view_name": "歌词视图",
33663378
"keys_manage_devices_description": "打开音源和设备选择器",
@@ -5364,8 +5376,14 @@
53645376
"keys_jump_to_artist_album_name": "前往藝人",
53655377
"keys_jump_to_context_description": "前往目前播放所屬清單",
53665378
"keys_jump_to_context_name": "前往所屬清單",
5379+
"keys_jump_to_end_description": "Jump to the last row of the list",
5380+
"keys_jump_to_end_name": "Jump to End",
5381+
"keys_jump_to_start_description": "Jump to the first row of the list",
5382+
"keys_jump_to_start_name": "Jump to Start",
53675383
"keys_like_track_description": "切換目前播放曲目或單集的收藏狀態",
53685384
"keys_like_track_name": "喜歡曲目",
5385+
"keys_listening_party_description": "Open the Listening Party menu",
5386+
"keys_listening_party_name": "Listening Party",
53695387
"keys_lyrics_view_description": "開啟歌詞畫面",
53705388
"keys_lyrics_view_name": "歌詞畫面",
53715389
"keys_manage_devices_description": "開啟來源和裝置選擇器",

‎src/core/app/settings_apply.rs‎

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -577,6 +577,20 @@ impl App {
577577
}
578578
}
579579
}
580+
"keys.jump_to_start" => {
581+
if let SettingValue::Key(v) = &setting.value {
582+
if let Ok(key) = crate::core::user_config::parse_key_public(v.clone()) {
583+
self.user_config.keys.jump_to_start = key;
584+
}
585+
}
586+
}
587+
"keys.jump_to_end" => {
588+
if let SettingValue::Key(v) = &setting.value {
589+
if let Ok(key) = crate::core::user_config::parse_key_public(v.clone()) {
590+
self.user_config.keys.jump_to_end = key;
591+
}
592+
}
593+
}
580594
"keys.toggle_playback" => {
581595
if let SettingValue::Key(v) = &setting.value {
582596
if let Ok(key) = crate::core::user_config::parse_key_public(v.clone()) {
@@ -689,6 +703,13 @@ impl App {
689703
}
690704
}
691705
}
706+
"keys.listening_party" => {
707+
if let SettingValue::Key(v) = &setting.value {
708+
if let Ok(key) = crate::core::user_config::parse_key_public(v.clone()) {
709+
self.user_config.keys.listening_party = key;
710+
}
711+
}
712+
}
692713
"keys.decrease_volume" => {
693714
if let SettingValue::Key(v) = &setting.value {
694715
if let Ok(key) = crate::core::user_config::parse_key_public(v.clone()) {

‎src/core/app/settings_schema.rs‎

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@ pub(crate) fn setting_requirement(id: &str) -> Requirement {
113113
| "keys.jump_to_album"
114114
| "keys.jump_to_artist_album"
115115
| "keys.jump_to_context"
116+
| "keys.listening_party"
116117
| "keys.copy_song_url"
117118
| "keys.copy_album_url" => Requirement::SpotifySession,
118119
// The like key favorites the station under Radio.
@@ -888,6 +889,18 @@ impl App {
888889
description: strings.keys_previous_page_description.to_string(),
889890
value: SettingValue::Key(key_to_config_string(&self.user_config.keys.previous_page)),
890891
},
892+
SettingItem {
893+
id: "keys.jump_to_start".to_string(),
894+
name: strings.keys_jump_to_start_name.to_string(),
895+
description: strings.keys_jump_to_start_description.to_string(),
896+
value: SettingValue::Key(key_to_config_string(&self.user_config.keys.jump_to_start)),
897+
},
898+
SettingItem {
899+
id: "keys.jump_to_end".to_string(),
900+
name: strings.keys_jump_to_end_name.to_string(),
901+
description: strings.keys_jump_to_end_description.to_string(),
902+
value: SettingValue::Key(key_to_config_string(&self.user_config.keys.jump_to_end)),
903+
},
891904
SettingItem {
892905
id: "keys.toggle_playback".to_string(),
893906
name: strings.keys_toggle_playback_name.to_string(),
@@ -988,6 +1001,12 @@ impl App {
9881001
description: strings.keys_manage_devices_description.to_string(),
9891002
value: SettingValue::Key(key_to_config_string(&self.user_config.keys.manage_devices)),
9901003
},
1004+
SettingItem {
1005+
id: "keys.listening_party".to_string(),
1006+
name: strings.keys_listening_party_name.to_string(),
1007+
description: strings.keys_listening_party_description.to_string(),
1008+
value: SettingValue::Key(key_to_config_string(&self.user_config.keys.listening_party)),
1009+
},
9911010
SettingItem {
9921011
id: "keys.decrease_volume".to_string(),
9931012
name: strings.keys_decrease_volume_name.to_string(),
@@ -1423,6 +1442,51 @@ mod tests {
14231442
);
14241443
}
14251444

1445+
#[test]
1446+
fn keybinding_rows_show_jump_and_party_keys() {
1447+
let app = keybinding_rows_with_f5_help_and_home_search();
1448+
for (id, value) in [
1449+
("keys.jump_to_start", "ctrl-a"),
1450+
("keys.jump_to_end", "ctrl-e"),
1451+
("keys.listening_party", "ctrl-p"),
1452+
] {
1453+
assert_eq!(key_row(&app, id), SettingValue::Key(value.to_string()));
1454+
}
1455+
}
1456+
1457+
#[test]
1458+
fn editing_jump_and_party_rows_applies_the_new_keys() {
1459+
let mut app = keybinding_rows_with_f5_help_and_home_search();
1460+
for (id, value) in [
1461+
("keys.jump_to_start", "f6"),
1462+
("keys.jump_to_end", "f7"),
1463+
("keys.listening_party", "f8"),
1464+
] {
1465+
let item = app
1466+
.settings_items
1467+
.iter_mut()
1468+
.find(|item| item.id == id)
1469+
.unwrap();
1470+
item.value = SettingValue::Key(value.to_string());
1471+
}
1472+
app.apply_settings_changes();
1473+
assert_eq!(app.user_config.keys.jump_to_start, Key::F6);
1474+
assert_eq!(app.user_config.keys.jump_to_end, Key::F7);
1475+
assert_eq!(app.user_config.keys.listening_party, Key::F8);
1476+
}
1477+
1478+
#[test]
1479+
fn the_listening_party_key_row_needs_a_spotify_session() {
1480+
let mut app = keybinding_rows_with_f5_help_and_home_search();
1481+
let requirement = setting_requirement("keys.listening_party");
1482+
assert!(!app.availability(requirement).is_available());
1483+
assert!(offered(&app, "keys.listening_party"));
1484+
assert_eq!(setting_requirement("keys.jump_to_start"), Requirement::None);
1485+
assert_eq!(setting_requirement("keys.jump_to_end"), Requirement::None);
1486+
app.spotify_connected = true;
1487+
assert!(app.availability(requirement).is_available());
1488+
}
1489+
14261490
#[test]
14271491
fn every_key_row_parses_back_as_a_key() {
14281492
let app = keybinding_rows_with_f5_help_and_home_search();

‎src/core/i18n/settings.rs‎

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,10 @@ pub struct SettingsStrings {
162162
pub keys_next_page_description: &'static str,
163163
pub keys_previous_page_name: &'static str,
164164
pub keys_previous_page_description: &'static str,
165+
pub keys_jump_to_start_name: &'static str,
166+
pub keys_jump_to_start_description: &'static str,
167+
pub keys_jump_to_end_name: &'static str,
168+
pub keys_jump_to_end_description: &'static str,
165169
pub keys_toggle_playback_name: &'static str,
166170
pub keys_toggle_playback_description: &'static str,
167171
pub keys_seek_backwards_name: &'static str,
@@ -194,6 +198,8 @@ pub struct SettingsStrings {
194198
pub keys_jump_to_context_description: &'static str,
195199
pub keys_manage_devices_name: &'static str,
196200
pub keys_manage_devices_description: &'static str,
201+
pub keys_listening_party_name: &'static str,
202+
pub keys_listening_party_description: &'static str,
197203
pub keys_decrease_volume_name: &'static str,
198204
pub keys_decrease_volume_description: &'static str,
199205
pub keys_increase_volume_name: &'static str,
@@ -661,6 +667,14 @@ impl SettingsStrings {
661667
self.keys_previous_page_name,
662668
self.keys_previous_page_description,
663669
),
670+
"keys.jump_to_start" => (
671+
self.keys_jump_to_start_name,
672+
self.keys_jump_to_start_description,
673+
),
674+
"keys.jump_to_end" => (
675+
self.keys_jump_to_end_name,
676+
self.keys_jump_to_end_description,
677+
),
664678
"keys.toggle_playback" => (
665679
self.keys_toggle_playback_name,
666680
self.keys_toggle_playback_description,
@@ -710,6 +724,10 @@ impl SettingsStrings {
710724
self.keys_manage_devices_name,
711725
self.keys_manage_devices_description,
712726
),
727+
"keys.listening_party" => (
728+
self.keys_listening_party_name,
729+
self.keys_listening_party_description,
730+
),
713731
"keys.decrease_volume" => (
714732
self.keys_decrease_volume_name,
715733
self.keys_decrease_volume_description,

‎src/core/i18n/settings/en.rs‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,10 @@ pub const EN: SettingsStrings = SettingsStrings {
153153
keys_next_page_description: "Navigate to next page",
154154
keys_previous_page_name: "Previous Page",
155155
keys_previous_page_description: "Navigate to previous page",
156+
keys_jump_to_start_name: "Jump to Start",
157+
keys_jump_to_start_description: "Jump to the first row of the list",
158+
keys_jump_to_end_name: "Jump to End",
159+
keys_jump_to_end_description: "Jump to the last row of the list",
156160
keys_toggle_playback_name: "Toggle Playback",
157161
keys_toggle_playback_description: "Play/pause",
158162
keys_seek_backwards_name: "Seek Backwards",
@@ -185,6 +189,8 @@ pub const EN: SettingsStrings = SettingsStrings {
185189
keys_jump_to_context_description: "Jump to current playback context",
186190
keys_manage_devices_name: "Switch Music Source",
187191
keys_manage_devices_description: "Open the source and device picker",
192+
keys_listening_party_name: "Listening Party",
193+
keys_listening_party_description: "Open the Listening Party menu",
188194
keys_decrease_volume_name: "Decrease Volume",
189195
keys_decrease_volume_description: "Decrease playback volume",
190196
keys_increase_volume_name: "Increase Volume",

0 commit comments

Comments
 (0)