Provide a keyboard shortcut to pull all release groups of an artist #233

Merged
wojtek merged 14 commits from 160---provide-a-keyboard-shortcut-to-pull-all-release-groups-of-an-artist into main 2024-12-30 23:42:20 +01:00
Showing only changes of commit ec61b2d50a - Show all commits

View File

@ -49,6 +49,14 @@ impl FetchState {
}
}
pub fn fetch(fetch_rx: MbApiReceiver) -> Self {
FetchState {
search_rx: None,
lookup_rx: None,
fetch_rx: Some(fetch_rx),
}
}
fn try_recv(&mut self) -> Result<MbApiResult, TryRecvError> {
try_recv_mb_api_receiver!(self.lookup_rx);
try_recv_mb_api_receiver!(self.search_rx);
@ -79,10 +87,10 @@ impl AppMachine<FetchState> {
return AppMachine::browse_state(inner).into();
}
let (fetch_tx, fetch_rx) = mpsc::channel::<MbApiResult>();
let fetch = FetchState::search(fetch_rx);
let (search_tx, search_rx) = mpsc::channel::<MbApiResult>();
let fetch = FetchState::search(search_rx);
match inner.musicbrainz.submit_background_job(fetch_tx, requests) {
match inner.musicbrainz.submit_background_job(search_tx, requests) {
Ok(()) => AppMachine::fetch_state(inner, fetch).into(),
Err(err) => AppMachine::error_state(inner, err.to_string()).into(),
}
@ -98,7 +106,13 @@ impl AppMachine<FetchState> {
},
Err(recv_err) => match recv_err {
TryRecvError::Empty => AppMachine::fetch_state(inner, fetch).into(),
TryRecvError::Disconnected => Self::app_fetch_new(inner),
TryRecvError::Disconnected => {
if fetch.fetch_rx.is_some() {
AppMachine::browse_state(inner).into()
} else {
Self::app_fetch_new(inner)
}
}
},
}
}
@ -198,6 +212,10 @@ impl AppMachine<FetchState> {
Self::search_albums_requests(artist_id, artist_mbid, slice::from_ref(album))
}
fn search_artist_request(meta: &ArtistMeta) -> VecDeque<MbParams> {
VecDeque::from([MbParams::search_artist(meta.clone())])
}
fn search_albums_requests(
artist: &ArtistId,
arid: &MbArtistRef,
@ -213,10 +231,6 @@ impl AppMachine<FetchState> {
.collect()
}
fn search_artist_request(meta: &ArtistMeta) -> VecDeque<MbParams> {
VecDeque::from([MbParams::search_artist(meta.clone())])
}
fn submit_lookup_artist_job(
musicbrainz: &dyn IMbJobSender,
result_sender: ResultSender,