Skip to content

Commit

Permalink
Remove unused code
Browse files Browse the repository at this point in the history
  • Loading branch information
oskarhane committed Oct 13, 2017
1 parent d8efa9b commit 3a96a92
Showing 1 changed file with 14 additions and 24 deletions.
38 changes: 14 additions & 24 deletions src/browser/components/DesktopIntegration/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,49 +22,39 @@ import { Component } from 'preact'
import { getActiveGraph, getCredentials, eventToHandler } from './helpers'

export default class DesktopIntegration extends Component {
state = {
listenerSetup: false,
cachedConnectionCredentials: {}
}
setupListener = props => {
if (this.state.listenerSetup) return
const { integrationPoint } = props
setupListener () {
const { integrationPoint } = this.props
// Run on context updates
if (integrationPoint && integrationPoint.onContextUpdate) {
const listenerSetup = () =>
integrationPoint.onContextUpdate((event, newContext, oldContext) => {
const handlerPropName = eventToHandler(event.type)
if (!handlerPropName) return
if (typeof this.props[handlerPropName] === 'undefined') return
this.props[handlerPropName](event, newContext, oldContext)
})
this.setState({ listenerSetup: true }, listenerSetup)
integrationPoint.onContextUpdate((event, newContext, oldContext) => {
const handlerPropName = eventToHandler(event.type)
if (!handlerPropName) return
if (typeof this.props[handlerPropName] === 'undefined') return
this.props[handlerPropName](event, newContext, oldContext)
})
}
}
checkContextForActiveConnection = props => {
const { integrationPoint } = props
checkContextForActiveConnection () {
const { integrationPoint, onMount = null } = this.props
if (integrationPoint && integrationPoint.getContext) {
integrationPoint
.getContext()
.then(context => {
const activeGraph = getActiveGraph(context)
if (this.props.onMount) {
if (onMount) {
const connectionCredentials = getCredentials(
'bolt',
activeGraph.connection
)
this.props.onMount(activeGraph, connectionCredentials, context)
onMount(activeGraph, connectionCredentials, context)
}
})
.catch(e => {}) // Catch but don't bother
}
}
componentDidMount () {
this.checkContextForActiveConnection(this.props)
this.setupListener(this.props)
}
componentWillReceiveProps (props) {
this.setupListener(props)
this.checkContextForActiveConnection()
this.setupListener()
}
render = () => {
return null
Expand Down

0 comments on commit 3a96a92

Please sign in to comment.