Clean up
This commit is contained in:
@@ -158,7 +158,6 @@ class UpdateNotifier extends React.Component<Props, {}> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private renderDownloads(updateInfo: UpdateInfo) {
|
private renderDownloads(updateInfo: UpdateInfo) {
|
||||||
console.log(updateInfo)
|
|
||||||
return updateInfo.files
|
return updateInfo.files
|
||||||
.map((file: UpdateFileInfo, index: number) => (
|
.map((file: UpdateFileInfo, index: number) => (
|
||||||
<div key={index}>
|
<div key={index}>
|
||||||
|
|||||||
@@ -90,31 +90,18 @@ class TreeNode extends React.Component<Props, State> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private writeStats(what: string) {
|
|
||||||
const w: any = window
|
|
||||||
if (!w.stats) {
|
|
||||||
w.stats = {}
|
|
||||||
}
|
|
||||||
if (!w.stats[what]) {
|
|
||||||
w.stats[what] = 0
|
|
||||||
}
|
|
||||||
w.stats[what] += 1
|
|
||||||
}
|
|
||||||
|
|
||||||
public componentDidMount() {
|
public componentDidMount() {
|
||||||
const { treeNode } = this.props
|
const { treeNode } = this.props
|
||||||
this.addSubscriber(treeNode)
|
this.addSubscriber(treeNode)
|
||||||
}
|
}
|
||||||
|
|
||||||
private addSubscriber(treeNode: q.TreeNode) {
|
private addSubscriber(treeNode: q.TreeNode) {
|
||||||
this.writeStats('subscribe')
|
|
||||||
treeNode.onMerge.subscribe(this.subnodesDidchange)
|
treeNode.onMerge.subscribe(this.subnodesDidchange)
|
||||||
treeNode.onEdgesChange.subscribe(this.edgesDidChange)
|
treeNode.onEdgesChange.subscribe(this.edgesDidChange)
|
||||||
treeNode.onMessage.subscribe(this.messageDidChange)
|
treeNode.onMessage.subscribe(this.messageDidChange)
|
||||||
}
|
}
|
||||||
|
|
||||||
private removeSubscriber(treeNode: q.TreeNode) {
|
private removeSubscriber(treeNode: q.TreeNode) {
|
||||||
this.writeStats('unsubscribe')
|
|
||||||
treeNode.onMerge.unsubscribe(this.subnodesDidchange)
|
treeNode.onMerge.unsubscribe(this.subnodesDidchange)
|
||||||
treeNode.onEdgesChange.unsubscribe(this.edgesDidChange)
|
treeNode.onEdgesChange.unsubscribe(this.edgesDidChange)
|
||||||
treeNode.onMessage.unsubscribe(this.messageDidChange)
|
treeNode.onMessage.unsubscribe(this.messageDidChange)
|
||||||
@@ -128,12 +115,8 @@ class TreeNode extends React.Component<Props, State> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public componentWillUnmount() {
|
public componentWillUnmount() {
|
||||||
this.writeStats('unsubscribe')
|
|
||||||
|
|
||||||
const { treeNode } = this.props
|
const { treeNode } = this.props
|
||||||
treeNode.onMerge.unsubscribe(this.subnodesDidchange)
|
this.removeSubscriber(treeNode)
|
||||||
treeNode.onEdgesChange.unsubscribe(this.edgesDidChange)
|
|
||||||
treeNode.onMessage.unsubscribe(this.messageDidChange)
|
|
||||||
this.topicSelectRef = undefined
|
this.topicSelectRef = undefined
|
||||||
this.titleRef = undefined
|
this.titleRef = undefined
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { Edge, TreeNode } from './'
|
import { TreeNode } from './'
|
||||||
import { EventBusInterface, makeConnectionMessageEvent, MqttMessage } from '../../../events'
|
import { EventBusInterface, makeConnectionMessageEvent, MqttMessage } from '../../../events'
|
||||||
import { TreeNodeFactory } from './TreeNodeFactory'
|
import { TreeNodeFactory } from './TreeNodeFactory'
|
||||||
|
|
||||||
@@ -40,7 +40,6 @@ export class Tree extends TreeNode {
|
|||||||
|
|
||||||
public stopUpdating() {
|
public stopUpdating() {
|
||||||
if (this.subscriptionEvent && this.updateSource) {
|
if (this.subscriptionEvent && this.updateSource) {
|
||||||
console.log(this.updateSource.ipc)
|
|
||||||
this.updateSource.unsubscribe(this.subscriptionEvent, this.handleNewData)
|
this.updateSource.unsubscribe(this.subscriptionEvent, this.handleNewData)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -70,7 +70,6 @@ class IpcRendererEventBus implements EventBusInterface {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public unsubscribe<MessageType>(event: Event<MessageType>, callback: any) {
|
public unsubscribe<MessageType>(event: Event<MessageType>, callback: any) {
|
||||||
debugger
|
|
||||||
const item = this.callbacks.find(store => store.callback === callback)
|
const item = this.callbacks.find(store => store.callback === callback)
|
||||||
if (!item) {
|
if (!item) {
|
||||||
return
|
return
|
||||||
|
|||||||
Reference in New Issue
Block a user