Skip to content

Commit 6024a19

Browse files
committed
Fix webui not polling selected server
1 parent 9a312fc commit 6024a19

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

webui/src/components/indexing_status/indexing_status.rs

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
use std::cell::RefCell;
2+
13
use crate::prelude::*;
24

35
mod ty;
@@ -7,6 +9,7 @@ pub use api::*;
79

810
pub struct IndexingStatusComp {
911
status: Option<IndexingStatus>,
12+
stop_polling: Rc<RefCell<bool>>,
1013
}
1114

1215
#[derive(PartialEq, Properties)]
@@ -23,11 +26,14 @@ impl Component for IndexingStatusComp {
2326
type Properties = IndexingStatusProps;
2427

2528
fn create(ctx: &Context<Self>) -> Self {
29+
let stop_polling = Rc::new(RefCell::new(false));
30+
2631
let link2 = ctx.link().clone();
2732
let rpc_addr2 = ctx.props().rpc_addr.clone();
33+
let stop_polling2 = Rc::clone(&stop_polling);
2834
spawn_local(async move {
2935
loop {
30-
if link2.get_component().is_none() {
36+
if *stop_polling2.borrow() {
3137
break;
3238
}
3339

@@ -50,6 +56,7 @@ impl Component for IndexingStatusComp {
5056

5157
Self {
5258
status: None,
59+
stop_polling,
5360
}
5461
}
5562

@@ -62,6 +69,12 @@ impl Component for IndexingStatusComp {
6269
}
6370
}
6471

72+
fn changed(&mut self, ctx: &Context<Self>, _old_props: &Self::Properties) -> bool {
73+
self.stop_polling.replace(true);
74+
*self = Component::create(ctx);
75+
true
76+
}
77+
6578
fn view(&self, _ctx: &Context<Self>) -> Html {
6679
let (exploring, indexing, building_filter, progress_value, progress_max) = match &self.status {
6780
Some(status) if status.to_list > 0 => (

0 commit comments

Comments
 (0)