Skip to content

Commit 28ca209

Browse files
committed
Fixes #872
1 parent e9683b3 commit 28ca209

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

app/components/search-input.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,10 @@ export default class SearchInput extends Component {
5656
}
5757

5858
@action onfocus() {
59+
if (this.query.length > 0 && this.searchService.hasStaleResults()) {
60+
this.searchService.search.perform(this.query);
61+
}
62+
5963
this._focused = true;
6064
}
6165

app/services/search.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@ export default Service.extend({
99
_projectService: service('project'),
1010
_projectVersion: alias('_projectService.version'),
1111

12+
/** @type {?string} */
13+
_lastQueriedProjectVersion: null,
14+
1215
results: emberArray(),
1316

1417
search: task(function* (query) {
@@ -30,6 +33,8 @@ export default Service.extend({
3033
query,
3134
};
3235

36+
this._lastQueriedProjectVersion = projectVersion;
37+
3338
return set(this, 'results', yield this.doSearch(searchObj, params));
3439
}).restartable(),
3540

@@ -38,4 +43,15 @@ export default Service.extend({
3843
.search(searchObj, params)
3944
.then((results) => results.hits);
4045
},
46+
47+
/**
48+
* Whenever the version changes in service:project, the results in this
49+
* service become stale. Presenting them any further could allow the user to
50+
* undo their version change by clicking a stale link.
51+
* @returns {boolean}
52+
*/
53+
hasStaleResults() {
54+
return this._lastQueriedProjectVersion !== null
55+
&& this._projectVersion !== this._lastQueriedProjectVersion;
56+
},
4157
});

0 commit comments

Comments
 (0)