Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions addon/components/docs-header/search-box/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,9 @@ export default class DocsHeaderSearchBox extends Component {
// the project) within a new addonDocs service that wires all that up together.
// I think it's fine if our Docs-* components assume there is a single global
// project.
@task
*fetchProject() {
yield this.store.findRecord('project', this.config.projectName);
}
fetchProject = task(async () => {
await this.store.findRecord('project', this.config.projectName);
});

@action
focusSearch() {
Expand Down
9 changes: 4 additions & 5 deletions addon/components/docs-header/search-results/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import Component from '@glimmer/component';
import { tracked } from '@glimmer/tracking';
import { action } from '@ember/object';
import { keyResponder, onKey } from 'ember-keyboard';
import { restartableTask } from 'ember-concurrency';
import { task } from 'ember-concurrency';
import { addonDocsConfig } from 'ember-cli-addon-docs/-private/config';

@keyResponder
Expand Down Expand Up @@ -32,17 +32,16 @@ export default class DocsHeaderSearchResults extends Component {
return this.args.query.trim();
}

@restartableTask
*search() {
search = task({ restartable: true }, async () => {
let results;

if (this.trimmedQuery) {
results = yield this.docsSearch.search(this.trimmedQuery);
results = await this.docsSearch.search(this.trimmedQuery);
}

this.selectedIndex = results.length ? 0 : null;
this.rawSearchResults = results;
}
});

get searchResults() {
let rawSearchResults = this.rawSearchResults;
Expand Down
11 changes: 5 additions & 6 deletions addon/services/docs-search.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import Service from '@ember/service';
import lunr from 'lunr';
import { enqueueTask } from 'ember-concurrency';
import { task } from 'ember-concurrency';
import {
getAddonDocsConfig,
getRootURL,
Expand Down Expand Up @@ -89,11 +89,10 @@ export default class DocsSearch extends Service {
return this._loadSearchIndex.perform();
}

@enqueueTask
*_loadSearchIndex() {
_loadSearchIndex = task({ enqueue: true }, async () => {
if (!this._searchIndex) {
let response = yield fetch(this._indexURL);
let json = yield response.json();
let response = await fetch(this._indexURL);
let json = await response.json();

this._searchIndex = {
index: Index.load(json.index),
Expand All @@ -102,7 +101,7 @@ export default class DocsSearch extends Service {
}

return this._searchIndex;
}
});

get _indexURL() {
return `${getRootURL(this)}ember-cli-addon-docs/search-index.json`;
Expand Down
9 changes: 4 additions & 5 deletions addon/services/project-version.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,11 @@ export default class ProjectVersionService extends Service {

@addonDocsConfig config;

@task
*_loadAvailableVersions() {
let response = yield fetch(`${this.root}versions.json`);
_loadAvailableVersions = task(async () => {
let response = await fetch(`${this.root}versions.json`);
let json;
if (response.ok) {
json = yield response.json();
json = await response.json();
} else {
json = {
[this.config.latestVersionName]: Object.assign({}, this.currentVersion),
Expand All @@ -30,7 +29,7 @@ export default class ProjectVersionService extends Service {

return version;
});
}
});

redirectTo(version) {
window.location.href = `${this.root}${version.path}`;
Expand Down
6 changes: 6 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,12 @@ module.exports = {
LATEST_VERSION_NAME,

options: {
babel: {
plugins: [
require.resolve('ember-concurrency/async-arrow-task-transform'),
],
},

postcssOptions: {
compile: {
extension: 'scss',
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
"ember-cli-version-checker": "^5.1.2",
"ember-code-snippet": "^3.0.0",
"ember-composable-helpers": "^5.0.0",
"ember-concurrency": "^3.1.1",
"ember-concurrency": "^5.1.0",
"ember-keyboard": "^9.0.1",
"ember-modal-dialog": "^4.1.4",
"ember-router-generator": "^2.0.0",
Expand Down
34 changes: 22 additions & 12 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.