File tree 2 files changed +30
-3
lines changed
2 files changed +30
-3
lines changed Original file line number Diff line number Diff line change 24
24
</div >
25
25
{{ /if }}
26
26
27
- {{ #if @crate .keywords}}
27
+ {{ #if this .keywords}}
28
28
<ul local-class =" keywords" >
29
- {{ #each @crate .keywords as |keyword |}}
29
+ {{ #each this .keywords as |keyword |}}
30
30
<li >
31
31
<LinkTo @route =" keyword" @model ={{ keyword.id }} data-test-keyword ={{ keyword.id }} >
32
32
<span local-class =" hash" >#</span >{{ keyword.id }}
Original file line number Diff line number Diff line change 1
1
import { inject as service } from '@ember/service' ;
2
2
import Component from '@glimmer/component' ;
3
3
4
+ import { task } from 'ember-concurrency' ;
5
+ import { alias } from 'macro-decorators' ;
6
+
4
7
export default class CrateHeader extends Component {
5
8
@service session ;
6
9
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
+
7
24
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 ) ;
9
28
}
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
+ } ) ;
10
37
}
You can’t perform that action at this time.
0 commit comments