Minor
This commit is contained in:
parent
494b75237e
commit
d84f769970
@ -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> {
|
fn try_recv(&mut self) -> Result<MbApiResult, TryRecvError> {
|
||||||
try_recv_mb_api_receiver!(self.lookup_rx);
|
try_recv_mb_api_receiver!(self.lookup_rx);
|
||||||
try_recv_mb_api_receiver!(self.search_rx);
|
try_recv_mb_api_receiver!(self.search_rx);
|
||||||
@ -79,10 +87,10 @@ impl AppMachine<FetchState> {
|
|||||||
return AppMachine::browse_state(inner).into();
|
return AppMachine::browse_state(inner).into();
|
||||||
}
|
}
|
||||||
|
|
||||||
let (fetch_tx, fetch_rx) = mpsc::channel::<MbApiResult>();
|
let (search_tx, search_rx) = mpsc::channel::<MbApiResult>();
|
||||||
let fetch = FetchState::search(fetch_rx);
|
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(),
|
Ok(()) => AppMachine::fetch_state(inner, fetch).into(),
|
||||||
Err(err) => AppMachine::error_state(inner, err.to_string()).into(),
|
Err(err) => AppMachine::error_state(inner, err.to_string()).into(),
|
||||||
}
|
}
|
||||||
@ -98,7 +106,13 @@ impl AppMachine<FetchState> {
|
|||||||
},
|
},
|
||||||
Err(recv_err) => match recv_err {
|
Err(recv_err) => match recv_err {
|
||||||
TryRecvError::Empty => AppMachine::fetch_state(inner, fetch).into(),
|
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))
|
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(
|
fn search_albums_requests(
|
||||||
artist: &ArtistId,
|
artist: &ArtistId,
|
||||||
arid: &MbArtistRef,
|
arid: &MbArtistRef,
|
||||||
@ -213,10 +231,6 @@ impl AppMachine<FetchState> {
|
|||||||
.collect()
|
.collect()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn search_artist_request(meta: &ArtistMeta) -> VecDeque<MbParams> {
|
|
||||||
VecDeque::from([MbParams::search_artist(meta.clone())])
|
|
||||||
}
|
|
||||||
|
|
||||||
fn submit_lookup_artist_job(
|
fn submit_lookup_artist_job(
|
||||||
musicbrainz: &dyn IMbJobSender,
|
musicbrainz: &dyn IMbJobSender,
|
||||||
result_sender: ResultSender,
|
result_sender: ResultSender,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user