Skip to content

Commit 07ada01

Browse files
committed
crate-header: Load crate.keywords explicitly with a task
This fixes the following deprecation warning: - Do not use A() on an EmberData PromiseManyArray.
1 parent 88ea6cb commit 07ada01

File tree

2 files changed

+19
-2
lines changed

2 files changed

+19
-2
lines changed

app/components/crate-header.hbs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,9 @@
2424
</div>
2525
{{/if}}
2626

27-
{{#if @crate.keywords}}
27+
{{#if this.keywords}}
2828
<ul local-class="keywords">
29-
{{#each @crate.keywords as |keyword|}}
29+
{{#each this.keywords as |keyword|}}
3030
<li>
3131
<LinkTo @route="keyword" @model={{keyword.id}} data-test-keyword={{keyword.id}}>
3232
<span local-class="hash">#</span>{{keyword.id}}

app/components/crate-header.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,27 @@
11
import { inject as service } from '@ember/service';
22
import Component from '@glimmer/component';
33

4+
import { task } from 'ember-concurrency';
5+
import { alias } from 'macro-decorators';
6+
47
export default class CrateHeader extends Component {
58
@service session;
69

10+
@alias('loadKeywordsTask.last.value') keywords;
11+
12+
constructor() {
13+
super(...arguments);
14+
15+
this.loadKeywordsTask.perform().catch(() => {
16+
// ignore all errors and just don't display keywords if the request fails
17+
});
18+
}
19+
720
get isOwner() {
821
return this.args.crate.owner_user.findBy('id', this.session.currentUser?.id);
922
}
23+
24+
loadKeywordsTask = task(async () => {
25+
return (await this.args.crate?.keywords) ?? [];
26+
});
1027
}

0 commit comments

Comments
 (0)