From a6685743763ac6d971afee81c1dc53e4c91695db Mon Sep 17 00:00:00 2001 From: Henrik Friedrichsen Date: Fri, 16 Sep 2022 22:12:37 +0200 Subject: [PATCH] Fix: properly set up Browse screen Previously two vectors of categories were created. The pagination was set up to store the newly fetched page in the `Vec` that was not displayed. With this change newly fetched pages should correctly show up in the "Browse" screen. As reported in #939 --- src/ui/browse.rs | 23 ++++------------------- 1 file changed, 4 insertions(+), 19 deletions(-) diff --git a/src/ui/browse.rs b/src/ui/browse.rs index 563ecb8..7ee7281 100644 --- a/src/ui/browse.rs +++ b/src/ui/browse.rs @@ -1,4 +1,4 @@ -use std::sync::{Arc, RwLock}; +use std::sync::Arc; use cursive::view::ViewWrapper; use cursive::Cursive; @@ -18,24 +18,9 @@ pub struct BrowseView { impl BrowseView { pub fn new(queue: Arc, library: Arc) -> Self { - let items = Arc::new(RwLock::new(Vec::new())); - let list = ListView::new(items.clone(), queue.clone(), library); - - let pagination = list.get_pagination().clone(); - std::thread::spawn(move || { - let categories = queue.get_spotify().api.categories(); - items - .write() - .expect("could not writelock category items") - .extend( - categories - .items - .read() - .expect("could not readlock fetched categories") - .clone(), - ); - categories.apply_pagination(&pagination); - }); + let categories = queue.get_spotify().api.categories(); + let list = ListView::new(categories.items.clone(), queue, library); + categories.apply_pagination(list.get_pagination()); Self { list } }