@@ -9,22 +9,23 @@ import AggregatorSetter from "../components/AggregatorSetter";
9
9
import available_aggregators from "../aggregators-list" ;
10
10
import { useRouter } from "next/router" ;
11
11
import EpochSettings from "../components/EpochSettings" ;
12
+ import { useDispatch , useSelector } from "react-redux" ;
13
+ import { toggleAutoUpdate } from "../store/settingsSlice" ;
12
14
13
15
function IntervalSetter ( props ) {
16
+ const autoUpdate = useSelector ( ( state ) => state . settings . autoUpdate ) ;
17
+ const dispatch = useDispatch ( ) ;
18
+
14
19
function handleChange ( event ) {
15
20
props . onIntervalChange ( parseInt ( event . target . value ) ) ;
16
21
}
17
22
18
- function handleClick ( ) {
19
- props . onStartStopPress ( ! props . isStartStopPressed ) ;
20
- }
21
-
22
23
return (
23
24
< Form . Group as = { Col } className = { props . className } >
24
25
< Form . Label > Update Interval:</ Form . Label >
25
26
< InputGroup >
26
- < Button type = "button" onClick = { handleClick } variant = { props . isStartStopPressed ? "primary" : "success" } >
27
- { props . isStartStopPressed ? "Pause ⏸" : "Resume ▶" }
27
+ < Button type = "button" onClick = { ( ) => dispatch ( toggleAutoUpdate ( ) ) } variant = { autoUpdate ? "primary" : "success" } >
28
+ { autoUpdate ? "Pause ⏸" : "Resume ▶" }
28
29
</ Button >
29
30
< Form . Select value = { props . interval } onChange = { handleChange } >
30
31
< option value = { 1000 } > 1 seconds</ option >
@@ -40,15 +41,15 @@ export default function Explorer() {
40
41
const router = useRouter ( ) ;
41
42
const [ aggregator , setAggregator ] = useState ( available_aggregators [ 0 ] ) ;
42
43
const [ interval , setInterval ] = useState ( 10000 ) ;
43
- const [ autoUpdate , setAutoUpdate ] = useState ( true ) ;
44
+ const autoUpdate = useSelector ( ( state ) => state . settings . autoUpdate ) ;
44
45
45
46
useEffect ( ( ) => {
46
47
if ( router . query ?. aggregator && router . query ?. aggregator !== aggregator ) {
47
- const autoUpdateState = autoUpdate ;
48
+ // const autoUpdateState = autoUpdate;
48
49
49
- setAutoUpdate ( false ) ;
50
+ // setAutoUpdate(false);
50
51
setAggregator ( router . query . aggregator ) ;
51
- setAutoUpdate ( autoUpdateState ) ;
52
+ // setAutoUpdate(autoUpdateState);
52
53
}
53
54
} , [ router . query ] ) ;
54
55
@@ -57,10 +58,6 @@ export default function Explorer() {
57
58
router . push ( { query : { aggregator : api } } ) . then ( ( ) => { } ) ;
58
59
}
59
60
60
- function handleStartStopButtonPress ( isPressed ) {
61
- setAutoUpdate ( isPressed ) ;
62
- }
63
-
64
61
function handleIntervalChange ( interval ) {
65
62
setInterval ( interval ) ;
66
63
}
@@ -85,17 +82,15 @@ export default function Explorer() {
85
82
defaultAvailableAggregators = { available_aggregators } />
86
83
< IntervalSetter
87
84
interval = { interval }
88
- onIntervalChange = { handleIntervalChange }
89
- isStartStopPressed = { autoUpdate }
90
- onStartStopPress = { handleStartStopButtonPress } />
85
+ onIntervalChange = { handleIntervalChange } />
91
86
</ Row >
92
87
</ Form >
93
88
< Row >
94
89
< Col >
95
- < EpochSettings aggregator = { aggregator } updateInterval = { interval } autoUpdate = { autoUpdate } />
90
+ < EpochSettings aggregator = { aggregator } updateInterval = { interval } />
96
91
</ Col >
97
92
< Col xs = { 8 } >
98
- < PendingCertificate aggregator = { aggregator } updateInterval = { interval } autoUpdate = { autoUpdate } />
93
+ < PendingCertificate aggregator = { aggregator } updateInterval = { interval } />
99
94
</ Col >
100
95
</ Row >
101
96
< SnapshotsList aggregator = { aggregator } updateInterval = { interval } autoUpdate = { autoUpdate } />
0 commit comments