diff --git a/connect/src/context_resolver.rs b/connect/src/context_resolver.rs index c66d2f12..01bc8c2a 100644 --- a/connect/src/context_resolver.rs +++ b/connect/src/context_resolver.rs @@ -148,8 +148,6 @@ pub struct ContextResolver { // time after which an unavailable context is retried const RETRY_UNAVAILABLE: Duration = Duration::from_secs(3600); -const CONCERNING_AMOUNT_OF_SKIPS: usize = 1_000; - impl ContextResolver { pub fn new(session: Session) -> Self { Self { @@ -211,14 +209,12 @@ impl ContextResolver { loop { let next = self.queue.front()?; match next.resolve_uri() { - // this is here to prevent an endless amount of skips - None if idx > CONCERNING_AMOUNT_OF_SKIPS => unreachable!(), - None => { + None if idx < self.queue.len() => { warn!("skipped {idx} because of no valid resolve_uri: {next}"); idx += 1; continue; } - Some(uri) => break Some((next, uri, idx)), + value => break value.map(|uri| (next, uri, idx)), } } } diff --git a/connect/src/spirc.rs b/connect/src/spirc.rs index 5b6ff91b..f6ad7e11 100644 --- a/connect/src/spirc.rs +++ b/connect/src/spirc.rs @@ -452,7 +452,7 @@ impl SpircTask { self.connect_state.prev_autoplay_track_uris() }).await }, if allow_context_resolving && self.context_resolver.has_next() => { - self.handle_context(next_context) + self.handle_next_context(next_context) }, else => break } @@ -471,7 +471,7 @@ impl SpircTask { self.session.dealer().close().await; } - fn handle_context(&mut self, next_context: Result) { + fn handle_next_context(&mut self, next_context: Result) { let next_context = match next_context { Err(why) => { self.context_resolver.mark_next_unavailable(); @@ -1026,7 +1026,7 @@ impl SpircTask { async fn handle_disconnect(&mut self) -> Result<(), Error> { self.context_resolver.clear(); - self.handle_stop(); + self.handle_pause(); self.play_status = SpircPlayStatus::Stopped {}; self.connect_state @@ -1115,7 +1115,7 @@ impl SpircTask { ContextAction::Replace, )); let context = self.context_resolver.get_next_context(Vec::new).await; - self.handle_context(context); + self.handle_next_context(context); } // for play commands with skip by uid, the context of the command contains