mirror of
https://github.com/socatlolmeow/drift.git
synced 2026-11-03 19:27:19 +00:00
fix clippy warnings in app.rs
This commit is contained in:
parent
678df67f08
commit
0fc9c0bb2c
1 changed files with 5 additions and 8 deletions
13
src/app.rs
13
src/app.rs
|
|
@ -237,7 +237,7 @@ impl App {
|
||||||
|
|
||||||
pub fn on_tick(&mut self) {
|
pub fn on_tick(&mut self) {
|
||||||
self.tick = self.tick.wrapping_add(1);
|
self.tick = self.tick.wrapping_add(1);
|
||||||
if self.tick % 50 == 0 {
|
if self.tick.is_multiple_of(50) {
|
||||||
match self.save_session(false) {
|
match self.save_session(false) {
|
||||||
Ok(()) => self.save_failed = false,
|
Ok(()) => self.save_failed = false,
|
||||||
Err(e) if !self.save_failed => {
|
Err(e) if !self.save_failed => {
|
||||||
|
|
@ -771,11 +771,11 @@ impl App {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn with_player(&mut self, f: impl Fn(&mut Player) -> Result<()>) -> Result<()> {
|
fn with_player(&mut self, f: impl Fn(&mut Player) -> Result<()>) -> Result<()> {
|
||||||
match self.ensure_player().and_then(|p| f(p)) {
|
match self.ensure_player().and_then(&f) {
|
||||||
Ok(()) => Ok(()),
|
Ok(()) => Ok(()),
|
||||||
Err(_) => {
|
Err(_) => {
|
||||||
self.player = None;
|
self.player = None;
|
||||||
self.ensure_player().and_then(|p| f(p))
|
self.ensure_player().and_then(f)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -797,7 +797,7 @@ impl App {
|
||||||
self.fail_streak = 0;
|
self.fail_streak = 0;
|
||||||
if let Some((id, pos)) = self.resume.take() {
|
if let Some((id, pos)) = self.resume.take() {
|
||||||
let ok = self.now_track().is_some_and(|t| {
|
let ok = self.now_track().is_some_and(|t| {
|
||||||
t.id == id && t.duration.map_or(true, |d| pos < f64::from(d) - 1.0)
|
t.id == id && t.duration.is_none_or(|d| pos < f64::from(d) - 1.0)
|
||||||
});
|
});
|
||||||
if ok && pos > 1.0 {
|
if ok && pos > 1.0 {
|
||||||
let _ = self.with_player(|p| p.seek_absolute(pos));
|
let _ = self.with_player(|p| p.seek_absolute(pos));
|
||||||
|
|
@ -1240,10 +1240,7 @@ impl App {
|
||||||
match self.view {
|
match self.view {
|
||||||
View::Queue => self.remove_from_queue(i),
|
View::Queue => self.remove_from_queue(i),
|
||||||
View::Playlists if self.in_playlist() => self.remove_playlist_track(i),
|
View::Playlists if self.in_playlist() => self.remove_playlist_track(i),
|
||||||
View::Playlists => match self.playlist_name(i) {
|
View::Playlists => if let Some(n) = self.playlist_name(i) { self.delete_playlist(&n) },
|
||||||
Some(n) => self.delete_playlist(&n),
|
|
||||||
None => {}
|
|
||||||
},
|
|
||||||
View::Results => self.info("Results can't be deleted — they are replaced by the next search"),
|
View::Results => self.info("Results can't be deleted — they are replaced by the next search"),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue