Skip to content

Commit 10b374d

Browse files
authored
Merge pull request #491 from chunqiuyiyu/dashboard-dev-search
Fix bug of searchAPI cyclic dependence
2 parents a7a3cdb + 241afa8 commit 10b374d

File tree

3 files changed

+10
-4
lines changed

3 files changed

+10
-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)
@@ -263,7 +262,6 @@ class SearchSocketClient {
263262
close () {
264263
const self = this
265264
if (config.searchSocketConnected) {
266-
searchAPI.searchWorkspaceDown();
267265
self.shouldClose = true;
268266
self.socket.close();
269267
// 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: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ 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'
11+
import config from 'config'
1012

1113
const hoverColor = '#337ab7'
1214

@@ -23,6 +25,7 @@ export class SearchResultItem extends Component {
2325
isFolded: !this.state.isFolded
2426
})
2527
}
28+
2629

2730
handleItemClick = (path, start, end, lineNum) => {
2831
const selection = new monaco.Selection(
@@ -72,7 +75,13 @@ export class SearchResultItem extends Component {
7275
@observer
7376
class SearchPanel extends Component {
7477
componentDidMount () {
75-
subscribeToSearch()
78+
subscribeToSearch()
79+
}
80+
81+
componentWillUnmount() {
82+
if (config.searchSocketConnected) {
83+
api.searchWorkspaceDown()
84+
}
7685
}
7786

7887
onKeyDown = (e) => {

0 commit comments

Comments
 (0)