blob: a517c34b3f112d8cbf0a2d113b61fc8210d415a2 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
|
import { goBack } from 'connected-react-router';
import log from 'electron-log';
import { connect } from 'react-redux';
import { bindActionCreators } from 'redux';
import { RelayLocation } from '../../shared/daemon-rpc-types';
import SelectLocation from '../components/SelectLocation';
import RelaySettingsBuilder from '../lib/relay-settings-builder';
import { IReduxState, ReduxDispatch } from '../redux/store';
import { ISharedRouteProps } from '../routes';
const mapStateToProps = (state: IReduxState) => ({
relaySettings: state.settings.relaySettings,
relayLocations: state.settings.relayLocations,
});
const mapDispatchToProps = (dispatch: ReduxDispatch, props: ISharedRouteProps) => {
const history = bindActionCreators({ goBack }, dispatch);
return {
onClose: () => history.goBack(),
onSelect: async (relayLocation: RelayLocation) => {
// dismiss the view first
history.goBack();
try {
const relayUpdate = RelaySettingsBuilder.normal()
.location.fromRaw(relayLocation)
.build();
await props.app.updateRelaySettings(relayUpdate);
await props.app.connectTunnel();
} catch (e) {
log.error(`Failed to select server: ${e.message}`);
}
},
};
};
export default connect(
mapStateToProps,
mapDispatchToProps,
)(SelectLocation);
|