Skip to content

Commit b411a99

Browse files
committed
ct and speeds
1 parent 350d089 commit b411a99

File tree

2 files changed

+29
-43
lines changed

2 files changed

+29
-43
lines changed

plugins/editor/indicators.js

Lines changed: 24 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,30 @@
22

33
const _ = require('lodash');
44
const React = require('react');
5-
const { createContainer } = require('sovereign');
65

76
const styles = require('./styles');
87
const transmissionStore = require('../../src/stores/transmission');
98

109
class Indicators extends React.Component {
1110

11+
constructor(){
12+
this._updateIndicators = this._updateIndicators.bind(this);
13+
}
14+
15+
_updateIndicators(){
16+
const { flashRx, flashTx } = transmissionStore.getState();
17+
if(flashRx){
18+
this.rx.style.backgroundColor = styles.rx.backgroundColor;
19+
} else {
20+
this.rx.style.backgroundColor = styles.indicator.backgroundColor;
21+
}
22+
if(flashTx){
23+
this.tx.style.backgroundColor = styles.tx.backgroundColor;
24+
} else {
25+
this.tx.style.backgroundColor = styles.indicator.backgroundColor;
26+
}
27+
}
28+
1229
componentDidMount() {
1330
var parent = React.findDOMNode(this);
1431
var tx = this.tx = document.createElement('span');
@@ -23,64 +40,28 @@ class Indicators extends React.Component {
2340
tx.style[name] = style;
2441
rx.style[name] = style;
2542
});
26-
console.log('componentDidMount', tx, rx, tx.style);
43+
44+
transmissionStore.listen(this._updateIndicators);
2745
}
2846

2947
componentWillUnmount() {
30-
console.log('componentWillUnmount');
3148
var parent = React.findDOMNode(this);
3249
parent.removeChild(this.tx);
3350
parent.removeChild(this.rx);
3451
this.tx = null;
3552
this.rx = null;
53+
transmissionStore.unlisten(this._updateIndicators);
3654
}
3755

38-
shouldComponentUpdate(nextProps) {
39-
const { flashRx, flashTx } = this.props;
40-
if(this.rx != null && nextProps.flashRx !== flashRx){
41-
if(nextProps.flashRx){
42-
this.rx.style.backgroundColor = styles.rx.backgroundColor;
43-
}else{
44-
this.rx.style.backgroundColor = styles.indicator.backgroundColor;
45-
}
46-
}
47-
if(this.tx != null && nextProps.flashTx !== flashTx){
48-
if(nextProps.flashTx){
49-
this.tx.style.backgroundColor = styles.tx.backgroundColor;
50-
}else{
51-
this.tx.style.backgroundColor = styles.indicator.backgroundColor;
52-
}
53-
}
56+
shouldComponentUpdate() {
5457
return false;
5558
}
5659

5760
render() {
58-
// const { flashRx, flashTx } = this.props;
59-
60-
// let indicatorRx = [styles.indicator];
61-
// let indicatorTx = [styles.indicator];
62-
// if(flashRx) {
63-
// indicatorRx.push(styles.rx);
64-
// }
65-
// if(flashTx) {
66-
// indicatorTx.push(styles.tx);
67-
// }
68-
//TX<span styles={indicatorTx} /> RX<span styles={indicatorRx} />
6961
return (
70-
<span style={styles.rxtx}>
71-
</span>
62+
<span style={styles.rxtx}></span>
7263
);
7364
}
7465
}
7566

76-
module.exports = createContainer(Indicators, {
77-
getStores(){
78-
return {
79-
deviceStore: transmissionStore
80-
};
81-
},
82-
83-
getPropsFromStores() {
84-
return transmissionStore.getState();
85-
}
86-
});
67+
module.exports = Indicators;

plugins/editor/transmit-pane.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,11 @@ class TransmitPane extends React.Component {
3838
transmitInput(data);
3939
}
4040

41+
shouldComponentUpdate(nextProps){
42+
const { connected, text } = this.props;
43+
return (connected !== nextProps.connected || text !== nextProps.text);
44+
}
45+
4146
render() {
4247
const { connected, text } = this.props;
4348
return (

0 commit comments

Comments
 (0)