Fix emitter leaks, style, tree swaps

This commit is contained in:
Thomas Nordquist
2019-01-22 12:17:59 +01:00
parent 221abd8c48
commit d4ce58a8ec
22 changed files with 411 additions and 164 deletions

View File

@@ -1,9 +1,8 @@
import * as React from 'react'
import * as q from '../../../../backend/src/Model'
import { Theme, withTheme } from '@material-ui/core/styles'
import BarChart from '@material-ui/icons/BarChart'
import DateFormatter from '../DateFormatter'
import DateFormatter from '../helper/DateFormatter'
import History from './History'
import PlotHistory from './PlotHistory'
@@ -11,7 +10,6 @@ const throttle = require('lodash.throttle')
interface Props {
node?: q.TreeNode
theme: Theme
onSelect: (message: q.Message) => void
}
@@ -35,7 +33,7 @@ class MessageHistory extends React.Component<Props, State> {
nextProps.node && nextProps.node.onMessage.subscribe(this.updateNode)
}
public componentWillMount() {
public componentDidMount() {
this.props.node && this.props.node.onMessage.subscribe(this.updateNode)
}
@@ -81,4 +79,4 @@ class MessageHistory extends React.Component<Props, State> {
}
}
export default withTheme()(MessageHistory)
export default MessageHistory

View File

@@ -1,10 +1,9 @@
const { XYPlot, XAxis, LineMarkSeries, Hint, YAxis, HorizontalGridLines, LineSeries } = require('react-vis')
import { default as ReactResizeDetector } from 'react-resize-detector'
import DateFormatter from '../DateFormatter'
import DateFormatter from '../helper/DateFormatter'
import * as React from 'react'
import * as q from '../../../../backend/src/Model'
import { withStyles, Theme, StyleRulesCallback } from '@material-ui/core/styles'
import 'react-vis/dist/style.css'
interface Props {
@@ -71,4 +70,4 @@ class PlotHistory extends React.Component<Props, Stats> {
}
}
export default withStyles({}, { withTheme: true })(PlotHistory)
export default PlotHistory

View File

@@ -7,11 +7,9 @@ import {
ExpansionPanelDetails,
ExpansionPanelSummary,
Fade,
Fab,
Paper,
Popper,
Typography,
IconButton,
Tooltip,
} from '@material-ui/core'
import { StyleRulesCallback, Theme, withStyles } from '@material-ui/core/styles'
@@ -20,7 +18,7 @@ import { sidebarActons } from '../../actions'
import { AppState } from '../../reducers'
import Copy from '../Copy'
import DateFormatter from '../DateFormatter'
import DateFormatter from '../helper/DateFormatter'
import ExpandMore from '@material-ui/icons/ExpandMore'
import Clear from '@material-ui/icons/Clear'
import MessageHistory from './MessageHistory'
@@ -37,7 +35,6 @@ interface Props {
node?: q.TreeNode,
actions: typeof sidebarActons,
classes: any,
theme: Theme,
connectionId?: string,
}
@@ -58,22 +55,6 @@ class Sidebar extends React.Component<Props, State> {
this.state = { node: new q.Tree() }
}
public static styles: StyleRulesCallback<string> = (theme: Theme) => {
return {
drawer: {
display: 'block',
height: '100%',
},
valuePaper: {
margin: `${theme.spacing.unit}px ${theme.spacing.unit}px ${theme.spacing.unit}px ${theme.spacing.unit}px`,
},
heading: {
fontSize: theme.typography.pxToRem(15),
fontWeight: theme.typography.fontWeightRegular,
},
}
}
public componentWillReceiveProps(nextProps: Props) {
this.props.node && this.removeUpdateListener(this.props.node)
nextProps.node && this.registerUpdateListener(nextProps.node)
@@ -229,4 +210,20 @@ const mapDispatchToProps = (dispatch: any) => {
}
}
export default withStyles(Sidebar.styles, { withTheme: true })(connect(mapStateToProps, mapDispatchToProps)(Sidebar))
const styles: StyleRulesCallback<string> = (theme: Theme) => {
return {
drawer: {
display: 'block',
height: '100%',
},
valuePaper: {
margin: `${theme.spacing.unit}px ${theme.spacing.unit}px ${theme.spacing.unit}px ${theme.spacing.unit}px`,
},
heading: {
fontSize: theme.typography.pxToRem(15),
fontWeight: theme.typography.fontWeightRegular,
},
}
}
export default withStyles(styles)(connect(mapStateToProps, mapDispatchToProps)(Sidebar))