fix: trigger UI redraw after fetching artist data in separate thread

fixes #91
This commit is contained in:
Henrik Friedrichsen
2019-09-08 21:11:59 +02:00
parent b7a6903908
commit 498724e2a4
2 changed files with 8 additions and 0 deletions

View File

@@ -749,4 +749,8 @@ impl Library {
self.save_cache(config::cache_path(CACHE_PLAYLISTS), self.playlists.clone());
}
pub fn trigger_redraw(&self) {
self.ev.trigger();
}
}

View File

@@ -37,10 +37,12 @@ impl ArtistView {
let top_tracks = top_tracks.clone();
let spotify = spotify.clone();
let id = artist.id.clone();
let library = library.clone();
thread::spawn(move || {
if let Some(id) = id {
if let Some(tracks) = spotify.artist_top_tracks(id) {
top_tracks.write().unwrap().extend(tracks);
library.trigger_redraw();
}
}
});
@@ -51,10 +53,12 @@ impl ArtistView {
let related = related.clone();
let spotify = spotify.clone();
let id = artist.id.clone();
let library = library.clone();
thread::spawn(move || {
if let Some(id) = id {
if let Some(artists) = spotify.artist_related_artists(id) {
related.write().unwrap().extend(artists);
library.trigger_redraw();
}
}
});