// @flow import * as React from 'react'; import { Layout, Container, Header } from './Layout'; import CustomScrollbars from './CustomScrollbars'; import Accordion from './Accordion'; import ChevronDownSVG from '../assets/images/icon-chevron-down.svg'; import ChevronUpSVG from '../assets/images/icon-chevron-up.svg'; import TickSVG from '../assets/images/icon-tick.svg'; import type { SettingsReduxState, RelayLocationRedux, RelayLocationCityRedux } from '../redux/settings/reducers'; import type { RelayLocation } from '../lib/ipc-facade'; export type SelectLocationProps = { settings: SettingsReduxState, onClose: () => void; onSelect: (location: RelayLocation) => void; }; type State = { expanded: Array }; export default class SelectLocation extends React.Component { _selectedCell: ?HTMLElement; _scrollView: ?CustomScrollbars; state = { expanded: [], }; constructor(props: SelectLocationProps, context?: any) { super(props, context); // set initially expanded country based on relaySettings const relaySettings = this.props.settings.relaySettings; if(relaySettings.normal) { const { location } = relaySettings.normal; if(location === 'any') { // no-op } else if(location.country) { this.state.expanded.push(location.country); } else if(location.city) { this.state.expanded.push(location.city[0]); } } } componentDidMount() { // restore scroll to selected cell const cell = this._selectedCell; const scrollView = this._scrollView; if(scrollView && cell) { scrollView.scrollToElement(cell, 'middle'); } } render() { return (