mirror of
https://github.com/talwat/lowfi
synced 2025-03-12 16:12:22 +00:00
fix: bug where text after ! in custom names wouldn't show up
This commit is contained in:
parent
840b1663e7
commit
1e3c66679c
@ -36,6 +36,8 @@
|
|||||||
clippy::integer_division,
|
clippy::integer_division,
|
||||||
clippy::cast_sign_loss,
|
clippy::cast_sign_loss,
|
||||||
clippy::cast_lossless,
|
clippy::cast_lossless,
|
||||||
|
clippy::arbitrary_source_item_ordering,
|
||||||
|
clippy::unused_trait_names
|
||||||
)]
|
)]
|
||||||
|
|
||||||
use clap::{Parser, Subcommand};
|
use clap::{Parser, Subcommand};
|
||||||
|
@ -187,7 +187,7 @@ impl Player {
|
|||||||
let volume = PersistentVolume::load().await?;
|
let volume = PersistentVolume::load().await?;
|
||||||
|
|
||||||
// Load the track list.
|
// Load the track list.
|
||||||
let list = List::load(&args.tracks).await?;
|
let list = List::load(args.tracks.as_ref()).await?;
|
||||||
|
|
||||||
// We should only shut up alsa forcefully on Linux if we really have to.
|
// We should only shut up alsa forcefully on Linux if we really have to.
|
||||||
#[cfg(target_os = "linux")]
|
#[cfg(target_os = "linux")]
|
||||||
@ -233,7 +233,9 @@ impl Player {
|
|||||||
///
|
///
|
||||||
/// This will also set `current` to the newly loaded song.
|
/// This will also set `current` to the newly loaded song.
|
||||||
pub async fn next(&self) -> eyre::Result<tracks::Decoded> {
|
pub async fn next(&self) -> eyre::Result<tracks::Decoded> {
|
||||||
let track = if let Some(track) = self.tracks.write().await.pop_front() {
|
// TODO: Consider replacing this with `unwrap_or_else` when async closures are stablized.
|
||||||
|
let track = self.tracks.write().await.pop_front();
|
||||||
|
let track = if let Some(track) = track {
|
||||||
track
|
track
|
||||||
} else {
|
} else {
|
||||||
// If the queue is completely empty, then fallback to simply getting a new track.
|
// If the queue is completely empty, then fallback to simply getting a new track.
|
||||||
|
@ -78,7 +78,10 @@ impl Info {
|
|||||||
if skip == formatted.len() {
|
if skip == formatted.len() {
|
||||||
formatted
|
formatted
|
||||||
} else {
|
} else {
|
||||||
#[allow(clippy::string_slice, /* We've already checked before that the bound is at an ASCII digit. */)]
|
#[expect(
|
||||||
|
clippy::string_slice,
|
||||||
|
reason = "We've already checked before that the bound is at an ASCII digit."
|
||||||
|
)]
|
||||||
String::from(&formatted[skip..])
|
String::from(&formatted[skip..])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -41,11 +41,10 @@ impl List {
|
|||||||
let random = rand::thread_rng().gen_range(1..self.lines.len());
|
let random = rand::thread_rng().gen_range(1..self.lines.len());
|
||||||
let line = self.lines[random].clone();
|
let line = self.lines[random].clone();
|
||||||
|
|
||||||
let split: Vec<&str> = line.split('!').collect();
|
if let Some((first, second)) = line.split_once('!') {
|
||||||
if split.len() == 1 {
|
(first.to_owned(), Some(second.to_owned()))
|
||||||
(line, None)
|
|
||||||
} else {
|
} else {
|
||||||
(split[0].to_owned(), Some(split[1].to_owned()))
|
(line, None)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -87,7 +86,7 @@ impl List {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Reads a [List] from the filesystem using the CLI argument provided.
|
/// Reads a [List] from the filesystem using the CLI argument provided.
|
||||||
pub async fn load(tracks: &Option<String>) -> eyre::Result<Self> {
|
pub async fn load(tracks: Option<&String>) -> eyre::Result<Self> {
|
||||||
if let Some(arg) = tracks {
|
if let Some(arg) = tracks {
|
||||||
// Check if the track is in ~/.local/share/lowfi, in which case we'll load that.
|
// Check if the track is in ~/.local/share/lowfi, in which case we'll load that.
|
||||||
let name = dirs::data_dir()
|
let name = dirs::data_dir()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user