diff --git a/app/components/crate-header.hbs b/app/components/crate-header.hbs
index ce34c18d8a2..be4e56664f8 100644
--- a/app/components/crate-header.hbs
+++ b/app/components/crate-header.hbs
@@ -24,9 +24,9 @@
{{/if}}
- {{#if @crate.keywords}}
+ {{#if this.keywords}}
- {{#each @crate.keywords as |keyword|}}
+ {{#each this.keywords as |keyword|}}
-
#{{keyword.id}}
diff --git a/app/components/crate-header.js b/app/components/crate-header.js
index b36d092f9a3..4b732844826 100644
--- a/app/components/crate-header.js
+++ b/app/components/crate-header.js
@@ -1,10 +1,37 @@
import { inject as service } from '@ember/service';
import Component from '@glimmer/component';
+import { task } from 'ember-concurrency';
+import { alias } from 'macro-decorators';
+
export default class CrateHeader extends Component {
@service session;
+ @alias('loadKeywordsTask.last.value') keywords;
+ @alias('loadOwnerUserTask.last.value') ownerUser;
+
+ constructor() {
+ super(...arguments);
+
+ this.loadKeywordsTask.perform().catch(() => {
+ // ignore all errors and just don't display keywords if the request fails
+ });
+ this.loadOwnerUserTask.perform().catch(() => {
+ // ignore all errors and just don't display settings if the request fails
+ });
+ }
+
get isOwner() {
- return this.args.crate.owner_user.findBy('id', this.session.currentUser?.id);
+ let ownerUser = this.ownerUser ?? [];
+ let currentUserId = this.session.currentUser?.id;
+ return ownerUser.some(({ id }) => id === currentUserId);
}
+
+ loadKeywordsTask = task(async () => {
+ return (await this.args.crate?.keywords) ?? [];
+ });
+
+ loadOwnerUserTask = task(async () => {
+ return (await this.args.crate?.owner_user) ?? [];
+ });
}