Skip to content

Commit b89825f

Browse files
authored
Merge branch 'master' into master
2 parents fe01b49 + 54b3d95 commit b89825f

File tree

12 files changed

+32
-30
lines changed

12 files changed

+32
-30
lines changed

.typos.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@
22
# Don't correct these words
33
iterm = "iterm"
44
Iterm = "Iterm"
5+
typ = "typ"

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -430,4 +430,4 @@ The application stores logs inside the `$APP_CACHE_FOLDER/spotify-player-*.log`
430430

431431
## Acknowledgement
432432

433-
`spotify_player` is written in [Rust](https://www.rust-lang.org) and is built on top of awesome libraries such as [tui-rs](https://github.com/fdehau/tui-rs), [rspotify](https://github.com/ramsayleung/rspotify), [librespot](https://github.com/librespot-org/librespot), and [many more](spotify_player/Cargo.toml). It's highly inspired by [spotify-tui](https://github.com/Rigellute/spotify-tui) and [ncspot](https://github.com/hrkfdn/ncspot).
433+
`spotify_player` is written in [Rust](https://www.rust-lang.org) and is built on top of awesome libraries such as [ratatui](https://github.com/ratatui/ratatui), [rspotify](https://github.com/ramsayleung/rspotify), [librespot](https://github.com/librespot-org/librespot), and [many more](spotify_player/Cargo.toml). It's highly inspired by [spotify-tui](https://github.com/Rigellute/spotify-tui) and [ncspot](https://github.com/hrkfdn/ncspot).

spotify_player/Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ edition = "2021"
66
license = "MIT"
77
description = "A Spotify player in the terminal with full feature parity"
88
repository = "https://github.com/aome510/spotify-player"
9-
keywords = ["spotify", "tui", "player"]
9+
keywords = ["spotify", "tui", "ratatui", "player"]
1010
readme = "../README.md"
1111

1212
[dependencies]
@@ -32,7 +32,7 @@ tokio = { version = "1.41.1", features = [
3232
"time",
3333
] }
3434
toml = "0.8.19"
35-
tui = { package = "ratatui", version = "0.29.0" }
35+
ratatui = { version = "0.29.0" }
3636
rand = "0.8.5"
3737
maybe-async = "0.2.10"
3838
async-trait = "0.1.83"

spotify_player/src/client/mod.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1831,11 +1831,25 @@ impl Client {
18311831

18321832
/// Process a list of albums, which includes
18331833
/// - sort albums by the release date
1834+
/// - sort albums by the type if `sort_artist_albums_by_type` config is enabled
18341835
fn process_artist_albums(albums: Vec<Album>) -> Vec<Album> {
18351836
let mut albums = albums.into_iter().collect::<Vec<_>>();
18361837

18371838
albums.sort_by(|x, y| x.release_date.partial_cmp(&y.release_date).unwrap());
18381839

1840+
if config::get_config().app_config.sort_artist_albums_by_type {
1841+
fn get_priority(album_type: &str) -> usize {
1842+
match album_type {
1843+
"album" => 0,
1844+
"single" => 1,
1845+
"appears_on" => 2,
1846+
"compilation" => 3,
1847+
_ => 4,
1848+
}
1849+
}
1850+
albums.sort_by_key(|a| get_priority(&a.album_type()));
1851+
}
1852+
18391853
albums.reverse();
18401854

18411855
albums

spotify_player/src/config/theme.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use std::str::FromStr;
22

33
use anyhow::Result;
44
use serde::Deserialize;
5-
use tui::style;
5+
use ratatui::style;
66

77
#[derive(Clone, Debug, Deserialize)]
88
/// Application theme configurations.

spotify_player/src/event/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ use crate::utils::map_join;
2323
use anyhow::{Context as _, Result};
2424

2525
use clipboard::{execute_copy_command, get_clipboard_content};
26-
use tui::widgets::ListState;
26+
use ratatui::widgets::ListState;
2727

2828
mod clipboard;
2929
mod page;

spotify_player/src/state/ui/mod.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ pub use popup::*;
1818
#[cfg(feature = "image")]
1919
pub struct ImageRenderInfo {
2020
pub url: String,
21-
pub render_area: tui::layout::Rect,
21+
pub render_area: ratatui::layout::Rect,
2222
/// indicates if the image is rendered
2323
pub rendered: bool,
2424
}
@@ -36,7 +36,7 @@ pub struct UIState {
3636

3737
/// The rectangle representing the playback progress bar,
3838
/// which is mainly used to handle mouse click events (for seeking command)
39-
pub playback_progress_bar_rect: tui::layout::Rect,
39+
pub playback_progress_bar_rect: ratatui::layout::Rect,
4040

4141
#[cfg(feature = "image")]
4242
pub last_cover_image_render_info: ImageRenderInfo,
@@ -116,7 +116,7 @@ impl UIState {
116116

117117
#[cfg(feature = "fzf")]
118118
use fuzzy_matcher::skim::SkimMatcherV2;
119-
use tui::layout::Rect;
119+
use ratatui::layout::Rect;
120120

121121
#[cfg(feature = "fzf")]
122122
fn fuzzy_search_items<'a, T: std::fmt::Display>(items: &'a [T], query: &str) -> Vec<&'a T> {

spotify_player/src/state/ui/page.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use crate::{
22
state::model::{Category, ContextId},
33
ui::single_line_input::LineInput,
44
};
5-
use tui::widgets::{ListState, TableState};
5+
use ratatui::widgets::{ListState, TableState};
66

77
#[derive(Clone, Debug)]
88
pub enum PageState {

spotify_player/src/state/ui/popup.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use crate::{
33
state::model::{Album, Artist, Episode, EpisodeId, Playlist, Show, Track, TrackId},
44
ui::single_line_input::LineInput,
55
};
6-
use tui::widgets::ListState;
6+
use ratatui::widgets::ListState;
77

88
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
99
pub enum PlaylistCreateCurrentField {

spotify_player/src/ui/mod.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use crate::{
88
},
99
};
1010
use anyhow::{Context as AnyhowContext, Result};
11-
use tui::{
11+
use ratatui::{
1212
layout::{Constraint, Layout, Rect},
1313
style::{Modifier, Style},
1414
text::{Line, Span, Text},
@@ -22,7 +22,7 @@ use tui::{
2222
#[cfg(feature = "image")]
2323
use crate::state::ImageRenderInfo;
2424

25-
type Terminal = tui::Terminal<tui::backend::CrosstermBackend<std::io::Stdout>>;
25+
type Terminal = ratatui::Terminal<ratatui::backend::CrosstermBackend<std::io::Stdout>>;
2626

2727
mod page;
2828
mod playback;
@@ -82,8 +82,8 @@ fn init_ui() -> Result<Terminal> {
8282
crossterm::terminal::EnterAlternateScreen,
8383
crossterm::event::EnableMouseCapture
8484
)?;
85-
let backend = tui::backend::CrosstermBackend::new(stdout);
86-
let mut terminal = tui::Terminal::new(backend)?;
85+
let backend = ratatui::backend::CrosstermBackend::new(stdout);
86+
let mut terminal = ratatui::Terminal::new(backend)?;
8787
terminal.clear()?;
8888
Ok(terminal)
8989
}

0 commit comments

Comments
 (0)