1
+ use std:: cell:: RefCell ;
2
+
1
3
use crate :: prelude:: * ;
2
4
3
5
mod ty;
@@ -7,6 +9,7 @@ pub use api::*;
7
9
8
10
pub struct IndexingStatusComp {
9
11
status : Option < IndexingStatus > ,
12
+ stop_polling : Rc < RefCell < bool > > ,
10
13
}
11
14
12
15
#[ derive( PartialEq , Properties ) ]
@@ -23,11 +26,14 @@ impl Component for IndexingStatusComp {
23
26
type Properties = IndexingStatusProps ;
24
27
25
28
fn create ( ctx : & Context < Self > ) -> Self {
29
+ let stop_polling = Rc :: new ( RefCell :: new ( false ) ) ;
30
+
26
31
let link2 = ctx. link ( ) . clone ( ) ;
27
32
let rpc_addr2 = ctx. props ( ) . rpc_addr . clone ( ) ;
33
+ let stop_polling2 = Rc :: clone ( & stop_polling) ;
28
34
spawn_local ( async move {
29
35
loop {
30
- if link2 . get_component ( ) . is_none ( ) {
36
+ if * stop_polling2 . borrow ( ) {
31
37
break ;
32
38
}
33
39
@@ -50,6 +56,7 @@ impl Component for IndexingStatusComp {
50
56
51
57
Self {
52
58
status : None ,
59
+ stop_polling,
53
60
}
54
61
}
55
62
@@ -62,6 +69,12 @@ impl Component for IndexingStatusComp {
62
69
}
63
70
}
64
71
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
+
65
78
fn view ( & self , _ctx : & Context < Self > ) -> Html {
66
79
let ( exploring, indexing, building_filter, progress_value, progress_max) = match & self . status {
67
80
Some ( status) if status. to_list > 0 => (
0 commit comments