fix playlist cache parsing
This commit is contained in:
@@ -20,11 +20,6 @@ pub enum PlaylistEvent {
|
|||||||
NewList(usize, Playlist),
|
NewList(usize, Playlist),
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Default, Serialize, Deserialize)]
|
|
||||||
pub struct PlaylistStore {
|
|
||||||
pub playlists: Vec<Playlist>,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
pub struct Playlists {
|
pub struct Playlists {
|
||||||
pub store: Arc<RwLock<Vec<Playlist>>>,
|
pub store: Arc<RwLock<Vec<Playlist>>>,
|
||||||
@@ -71,13 +66,13 @@ impl Playlists {
|
|||||||
"loading playlist cache from {}",
|
"loading playlist cache from {}",
|
||||||
cache_path.to_str().unwrap()
|
cache_path.to_str().unwrap()
|
||||||
);
|
);
|
||||||
let parsed: Result<PlaylistStore, _> = serde_json::from_str(&contents);
|
let parsed: Result<Vec<Playlist>, _> = serde_json::from_str(&contents);
|
||||||
match parsed {
|
match parsed {
|
||||||
Ok(cache) => {
|
Ok(cache) => {
|
||||||
debug!("playlist cache loaded ({} lists)", cache.playlists.len());
|
debug!("playlist cache loaded ({} lists)", cache.len());
|
||||||
let mut store = self.store.write().expect("can't writelock playlist store");
|
let mut store = self.store.write().expect("can't writelock playlist store");
|
||||||
store.clear();
|
store.clear();
|
||||||
store.extend(cache.playlists);
|
store.extend(cache);
|
||||||
|
|
||||||
// force refresh of UI (if visible)
|
// force refresh of UI (if visible)
|
||||||
self.ev.send(Event::ScreenChange("playlists".to_owned()));
|
self.ev.send(Event::ScreenChange("playlists".to_owned()));
|
||||||
|
|||||||
Reference in New Issue
Block a user