Skip to content
This repository was archived by the owner on Jan 11, 2023. It is now read-only.

Commit a9ef15f

Browse files
atwalg2jasonLaster
authored andcommitted
[QuickOpen] Fix loading for searching symbols (#5653)
1 parent ba8aa69 commit a9ef15f

File tree

2 files changed

+17
-28
lines changed

2 files changed

+17
-28
lines changed

src/components/QuickOpenModal.js

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@ import {
1515
getQuickOpenType,
1616
getSelectedSource,
1717
getSymbols,
18-
getTabs
18+
getTabs,
19+
isSymbolsLoading
1920
} from "../selectors";
2021
import { scrollList } from "../utils/result-list";
2122
import {
@@ -46,6 +47,7 @@ type Props = {
4647
query: string,
4748
searchType: QuickOpenType,
4849
symbols: FormattedSymbolDeclarations,
50+
symbolsLoading: boolean,
4951
tabs: string[],
5052
selectLocation: Location => void,
5153
setQuickOpenQuery: (query: string) => void,
@@ -362,8 +364,18 @@ export class QuickOpenModal extends Component<Props, State> {
362364
return !this.getResultCount() && !!query;
363365
}
364366

367+
renderLoading = () => {
368+
const { symbolsLoading } = this.props;
369+
370+
if ((this.isFunctionQuery() || this.isVariableQuery()) && symbolsLoading) {
371+
return (
372+
<div className="loading-indicator">{L10N.getStr("loadingText")}</div>
373+
);
374+
}
375+
};
376+
365377
render() {
366-
const { enabled, query, symbols } = this.props;
378+
const { enabled, query } = this.props;
367379
const { selectedIndex, results } = this.state;
368380

369381
if (!enabled) {
@@ -388,12 +400,7 @@ export class QuickOpenModal extends Component<Props, State> {
388400
expanded && items[selectedIndex] ? items[selectedIndex].id : ""
389401
}
390402
/>
391-
{!symbols ||
392-
(symbols.functions.length == 0 && (
393-
<div className="loading-indicator">
394-
{L10N.getStr("loadingText")}
395-
</div>
396-
))}
403+
{this.renderLoading()}
397404
{newResults && (
398405
<ResultList
399406
key="results"
@@ -413,16 +420,13 @@ export class QuickOpenModal extends Component<Props, State> {
413420
/* istanbul ignore next: ignoring testing of redux connection stuff */
414421
function mapStateToProps(state) {
415422
const selectedSource = getSelectedSource(state);
416-
let symbols = null;
417-
if (selectedSource != null) {
418-
symbols = getSymbols(state, selectedSource.toJS());
419-
}
420423

421424
return {
422425
enabled: getQuickOpenEnabled(state),
423426
sources: formatSources(getSources(state)),
424427
selectedSource,
425-
symbols: formatSymbols(symbols),
428+
symbols: formatSymbols(getSymbols(state, selectedSource)),
429+
symbolsLoading: isSymbolsLoading(state, selectedSource),
426430
query: getQuickOpenQuery(state),
427431
searchType: getQuickOpenType(state),
428432
tabs: getTabs(state).toArray()

src/components/tests/__snapshots__/QuickOpenModal.spec.js.snap

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -117,11 +117,6 @@ exports[`QuickOpenModal Basic render with mount & searchType = functions 1`] = `
117117
</CloseButton>
118118
</div>
119119
</SearchInput>
120-
<div
121-
className="loading-indicator"
122-
>
123-
Loading…
124-
</div>
125120
<ResultList
126121
expanded={false}
127122
items={Array []}
@@ -263,11 +258,6 @@ exports[`QuickOpenModal Basic render with mount & searchType = variables 1`] = `
263258
</CloseButton>
264259
</div>
265260
</SearchInput>
266-
<div
267-
className="loading-indicator"
268-
>
269-
Loading…
270-
</div>
271261
<ResultList
272262
expanded={false}
273263
items={Array []}
@@ -577,11 +567,6 @@ exports[`QuickOpenModal Simple goto search query = :abc & searchType = goto 1`]
577567
</CloseButton>
578568
</div>
579569
</SearchInput>
580-
<div
581-
className="loading-indicator"
582-
>
583-
Loading…
584-
</div>
585570
</div>
586571
</div>
587572
</Modal>

0 commit comments

Comments
 (0)