-
Notifications
You must be signed in to change notification settings - Fork 606
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #10182 from eth3lbert/fix-crate-header
crate-header: Fix deprecation warnings
- Loading branch information
Showing
2 changed files
with
30 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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) ?? []; | ||
}); | ||
} |