Fixed a bug with cancelling tokens when processing prompt networking events
This commit is contained in:
@@ -148,7 +148,7 @@ impl<'a> App<'a> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if self.is_routing {
|
if self.is_routing {
|
||||||
if self.is_loading {
|
if self.is_loading && !self.should_refresh {
|
||||||
self.cancellation_token.cancel();
|
self.cancellation_token.cancel();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -535,6 +535,7 @@ mod tests {
|
|||||||
let (mut app, mut sync_network_rx) = construct_app_unit();
|
let (mut app, mut sync_network_rx) = construct_app_unit();
|
||||||
app.is_routing = true;
|
app.is_routing = true;
|
||||||
app.is_loading = true;
|
app.is_loading = true;
|
||||||
|
app.should_refresh = false;
|
||||||
|
|
||||||
app
|
app
|
||||||
.radarr_on_tick(ActiveRadarrBlock::Downloads, false)
|
.radarr_on_tick(ActiveRadarrBlock::Downloads, false)
|
||||||
@@ -583,6 +584,27 @@ mod tests {
|
|||||||
assert!(!app.data.radarr_data.prompt_confirm);
|
assert!(!app.data.radarr_data.prompt_confirm);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[tokio::test]
|
||||||
|
async fn test_radarr_on_tick_should_refresh_does_not_cancel_prompt_requests() {
|
||||||
|
let (mut app, mut sync_network_rx) = construct_app_unit();
|
||||||
|
app.is_loading = true;
|
||||||
|
app.is_routing = true;
|
||||||
|
app.should_refresh = true;
|
||||||
|
|
||||||
|
app
|
||||||
|
.radarr_on_tick(ActiveRadarrBlock::Downloads, false)
|
||||||
|
.await;
|
||||||
|
|
||||||
|
assert_eq!(
|
||||||
|
sync_network_rx.recv().await.unwrap(),
|
||||||
|
RadarrEvent::GetDownloads.into()
|
||||||
|
);
|
||||||
|
assert!(app.is_loading);
|
||||||
|
assert!(app.should_refresh);
|
||||||
|
assert!(!app.data.radarr_data.prompt_confirm);
|
||||||
|
assert!(!app.cancellation_token.is_cancelled());
|
||||||
|
}
|
||||||
|
|
||||||
#[tokio::test]
|
#[tokio::test]
|
||||||
async fn test_radarr_on_tick_network_tick_frequency() {
|
async fn test_radarr_on_tick_network_tick_frequency() {
|
||||||
let (mut app, mut sync_network_rx) = construct_app_unit();
|
let (mut app, mut sync_network_rx) = construct_app_unit();
|
||||||
|
|||||||
Reference in New Issue
Block a user