Skip to content

Commit 3dc5dd2

Browse files
authored
Merge pull request #10182 from eth3lbert/fix-crate-header
crate-header: Fix deprecation warnings
2 parents 88ea6cb + 914964e commit 3dc5dd2

File tree

2 files changed

+30
-3
lines changed

2 files changed

+30
-3
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: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,37 @@
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+
@alias('loadOwnerUserTask.last.value') ownerUser;
12+
13+
constructor() {
14+
super(...arguments);
15+
16+
this.loadKeywordsTask.perform().catch(() => {
17+
// ignore all errors and just don't display keywords if the request fails
18+
});
19+
this.loadOwnerUserTask.perform().catch(() => {
20+
// ignore all errors and just don't display settings if the request fails
21+
});
22+
}
23+
724
get isOwner() {
8-
return this.args.crate.owner_user.findBy('id', this.session.currentUser?.id);
25+
let ownerUser = this.ownerUser ?? [];
26+
let currentUserId = this.session.currentUser?.id;
27+
return ownerUser.some(({ id }) => id === currentUserId);
928
}
29+
30+
loadKeywordsTask = task(async () => {
31+
return (await this.args.crate?.keywords) ?? [];
32+
});
33+
34+
loadOwnerUserTask = task(async () => {
35+
return (await this.args.crate?.owner_user) ?? [];
36+
});
1037
}

0 commit comments

Comments
 (0)