From 3a96a92890e08e0f204dbb06499e1046b00d2cb4 Mon Sep 17 00:00:00 2001 From: Oskar Hane Date: Fri, 13 Oct 2017 16:39:58 +0200 Subject: [PATCH] Remove unused code --- .../components/DesktopIntegration/index.jsx | 38 +++++++------------ 1 file changed, 14 insertions(+), 24 deletions(-) diff --git a/src/browser/components/DesktopIntegration/index.jsx b/src/browser/components/DesktopIntegration/index.jsx index 05d87c18901..ab8003fa7ef 100644 --- a/src/browser/components/DesktopIntegration/index.jsx +++ b/src/browser/components/DesktopIntegration/index.jsx @@ -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