aboutsummaryrefslogtreecommitdiffstats
path: root/web/src/js/components/ProxyApp.jsx
diff options
context:
space:
mode:
authorMaximilian Hils <git@maximilianhils.com>2016-06-23 23:38:19 -0700
committerMaximilian Hils <git@maximilianhils.com>2016-06-23 23:38:19 -0700
commit21c3480429108cbbd45f5ae3de7a36d15460cdc3 (patch)
tree43f7df8c382bee7b9e5feb831379541685cfb4c0 /web/src/js/components/ProxyApp.jsx
parented05d3f858fb6b7c93b2353c947d88b3aefcd1ae (diff)
parent57af1d00ddd16bd36609a8c6dbf61411f5cd504c (diff)
downloadmitmproxy-21c3480429108cbbd45f5ae3de7a36d15460cdc3.tar.gz
mitmproxy-21c3480429108cbbd45f5ae3de7a36d15460cdc3.tar.bz2
mitmproxy-21c3480429108cbbd45f5ae3de7a36d15460cdc3.zip
Merge remote-tracking branch 'jason/websocket'
Diffstat (limited to 'web/src/js/components/ProxyApp.jsx')
-rw-r--r--web/src/js/components/ProxyApp.jsx58
1 files changed, 36 insertions, 22 deletions
diff --git a/web/src/js/components/ProxyApp.jsx b/web/src/js/components/ProxyApp.jsx
index 5d795b57..84564c32 100644
--- a/web/src/js/components/ProxyApp.jsx
+++ b/web/src/js/components/ProxyApp.jsx
@@ -3,6 +3,7 @@ import ReactDOM from 'react-dom'
import _ from 'lodash'
import { connect } from 'react-redux'
+import { init as appInit, destruct as appDestruct } from '../ducks/app'
import Header from './Header'
import EventLog from './EventLog'
import Footer from './Footer'
@@ -26,27 +27,8 @@ class ProxyAppMain extends Component {
this.updateLocation = this.updateLocation.bind(this)
}
- /**
- * @todo move to actions
- */
- updateLocation(pathname, queryUpdate) {
- if (pathname === undefined) {
- pathname = this.props.location.pathname
- }
- const query = this.props.location.query
- for (const key of Object.keys(queryUpdate || {})) {
- query[key] = queryUpdate[key] || undefined
- }
- this.context.router.replace({ pathname, query })
- }
-
- /**
- * @todo pass in with props
- */
- getQuery() {
- // For whatever reason, react-router always returns the same object, which makes comparing
- // the current props with nextProps impossible. As a workaround, we just clone the query object.
- return _.clone(this.props.location.query)
+ componentWillMount() {
+ this.props.appInit()
}
/**
@@ -56,6 +38,10 @@ class ProxyAppMain extends Component {
this.focus()
}
+ componentWillUnmount() {
+ this.props.appDestruct()
+ }
+
/**
* @todo use props
*/
@@ -110,6 +96,29 @@ class ProxyAppMain extends Component {
e.preventDefault()
}
+ /**
+ * @todo move to actions
+ */
+ updateLocation(pathname, queryUpdate) {
+ if (pathname === undefined) {
+ pathname = this.props.location.pathname
+ }
+ const query = this.props.location.query
+ for (const key of Object.keys(queryUpdate || {})) {
+ query[key] = queryUpdate[key] || undefined
+ }
+ this.context.router.replace({ pathname, query })
+ }
+
+ /**
+ * @todo pass in with props
+ */
+ getQuery() {
+ // For whatever reason, react-router always returns the same object, which makes comparing
+ // the current props with nextProps impossible. As a workaround, we just clone the query object.
+ return _.clone(this.props.location.query)
+ }
+
render() {
const { showEventLog, location, children } = this.props
const query = this.getQuery()
@@ -132,5 +141,10 @@ class ProxyAppMain extends Component {
export default connect(
state => ({
showEventLog: state.eventLog.visible,
- })
+ settings: state.settings.settings,
+ }),
+ {
+ appInit,
+ appDestruct,
+ }
)(ProxyAppMain)