Fix: fixes a bug that crashed ncspot.

Like mentioned in the corresponding issue by ayushjaipuriyar, ncspot
would crash when the queue was empty, shuffled, and played. This commit
fixes that, together with some minor clippy fixes.
This commit is contained in:
Thomas Frans
2022-09-30 17:42:23 +02:00
committed by Henrik Friedrichsen
parent be7ed20897
commit 655d663aed
3 changed files with 7 additions and 3 deletions

View File

@@ -204,7 +204,7 @@ impl View for CoverView {
}
});
let cover_url = self.queue.get_current().map(|t| t.cover_url()).flatten();
let cover_url = self.queue.get_current().and_then(|t| t.cover_url());
if let Some(url) = cover_url {
self.draw_cover(url, printer.offset, printer.size);

View File

@@ -143,6 +143,7 @@ impl Layout {
self.get_focussed_stack_mut().map(|stack| stack.pop());
}
#[allow(clippy::borrowed_box)]
fn get_current_screen(&self) -> Option<&Box<dyn ViewExt>> {
self.focus
.as_ref()
@@ -168,6 +169,7 @@ impl Layout {
.unwrap_or(false)
}
#[allow(clippy::borrowed_box)]
fn get_top_view(&self) -> Option<&Box<dyn ViewExt>> {
let focussed_stack = self.get_focussed_stack();
if focussed_stack.map(|s| s.len()).unwrap_or_default() > 0 {