Skip to content

Commit 99d5bc6

Browse files
author
春秋一语
authored
Merge pull request #492 from chunqiuyiyu/dashboard-dev-search
Fix bug of searchAPI cyclic dependence
2 parents fa67bd8 + 0f6ebdf commit 99d5bc6

File tree

3 files changed

+7
-4
lines changed

3 files changed

+7
-4
lines changed

app/backendAPI/websocketClients.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import emitter, * as E from 'utils/emitter'
55
import config from 'config'
66
import { autorun, runInAction } from 'mobx'
77
import { notify, NOTIFY_TYPE } from '../components/Notification/actions'
8-
import * as searchAPI from 'backendAPI/searchAPI'
98

109
const log = console.log || (x => x)
1110
const warn = console.warn || (x => x)
@@ -265,7 +264,6 @@ class SearchSocketClient {
265264
close () {
266265
const self = this
267266
if (config.searchSocketConnected) {
268-
searchAPI.searchWorkspaceDown();
269267
self.shouldClose = true;
270268
self.socket.close();
271269
// must emit ???

app/commons/Search/subscribeToSearch.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
import { SearchSocketClient } from 'backendAPI/websocketClients'
32
import { autorun } from 'mobx'
43
import state from './state'

app/components/Search/search.jsx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import { openFile } from 'commands/commandBindings/file'
77
import * as delegate from 'commons/Search/action'
88
import icons from 'file-icons-js'
99
import { Aa, Word, Reg } from './icons'
10+
import * as api from 'backendAPI/searchAPI'
1011

1112
const hoverColor = '#337ab7'
1213

@@ -23,6 +24,7 @@ export class SearchResultItem extends Component {
2324
isFolded: !this.state.isFolded
2425
})
2526
}
27+
2628

2729
handleItemClick = (path, start, end, lineNum) => {
2830
const selection = new monaco.Selection(
@@ -72,7 +74,11 @@ export class SearchResultItem extends Component {
7274
@observer
7375
class SearchPanel extends Component {
7476
componentDidMount () {
75-
subscribeToSearch()
77+
subscribeToSearch()
78+
}
79+
80+
componentWillUnmount() {
81+
api.searchWorkspaceDown()
7682
}
7783

7884
onKeyDown = (e) => {

0 commit comments

Comments
 (0)