blob: cd87610944f45d1d3a75ddf22bd9bb7cb0fb8af5 (
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
|
import * as React from 'react';
import { Component, Styles } from 'reactxp';
import { colors } from '../../config.json';
import { compareRelayLocation, RelayLocation } from '../../shared/daemon-rpc-types';
import * as Cell from './Cell';
import RelayStatusIndicator from './RelayStatusIndicator';
interface IProps {
location: RelayLocation;
active: boolean;
hostname: string;
selected: boolean;
onSelect?: (location: RelayLocation) => void;
}
const styles = {
base: Styles.createViewStyle({
paddingRight: 0,
paddingLeft: 48,
backgroundColor: colors.blue20,
}),
};
export default class RelayRow extends Component<IProps> {
public static compareProps(oldProps: IProps, nextProps: IProps) {
return (
oldProps.hostname === nextProps.hostname &&
oldProps.selected === nextProps.selected &&
oldProps.active === nextProps.active &&
compareRelayLocation(oldProps.location, nextProps.location)
);
}
public shouldComponentUpdate(nextProps: IProps) {
return !RelayRow.compareProps(this.props, nextProps);
}
public render() {
return (
<Cell.CellButton
onPress={this.handlePress}
selected={this.props.selected}
disabled={!this.props.active}
style={styles.base}>
<RelayStatusIndicator active={this.props.active} selected={this.props.selected} />
<Cell.Label>{this.props.hostname}</Cell.Label>
</Cell.CellButton>
);
}
private handlePress = () => {
if (this.props.onSelect) {
this.props.onSelect(this.props.location);
}
};
}
|