Skip to content

Commit 914964e

Browse files
committed
crate-header: Load crate.owner_user explicitly with a task
This fixes the following deprecation warnings: - The findBy method on ember-data's PromiseManyArray is deprecated. - The `findBy` method on the class ManyArray is deprecated.
1 parent 07ada01 commit 914964e

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

app/components/crate-header.js

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,20 +8,30 @@ export default class CrateHeader extends Component {
88
@service session;
99

1010
@alias('loadKeywordsTask.last.value') keywords;
11+
@alias('loadOwnerUserTask.last.value') ownerUser;
1112

1213
constructor() {
1314
super(...arguments);
1415

1516
this.loadKeywordsTask.perform().catch(() => {
1617
// ignore all errors and just don't display keywords if the request fails
1718
});
19+
this.loadOwnerUserTask.perform().catch(() => {
20+
// ignore all errors and just don't display settings if the request fails
21+
});
1822
}
1923

2024
get isOwner() {
21-
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);
2228
}
2329

2430
loadKeywordsTask = task(async () => {
2531
return (await this.args.crate?.keywords) ?? [];
2632
});
33+
34+
loadOwnerUserTask = task(async () => {
35+
return (await this.args.crate?.owner_user) ?? [];
36+
});
2737
}

0 commit comments

Comments
 (0)