File tree Expand file tree Collapse file tree 2 files changed +4
-19
lines changed Expand file tree Collapse file tree 2 files changed +4
-19
lines changed Original file line number Diff line number Diff line change 1
1
import ApplicationAdapter from './application' ;
2
2
3
3
export default ApplicationAdapter . extend ( {
4
- follow ( id ) {
5
- return this . ajax ( this . urlForFollowAction ( id ) , 'PUT' ) ;
6
- } ,
7
-
8
4
async inviteOwner ( id , username ) {
9
5
let result = await this . ajax ( this . urlForOwnerAction ( id ) , 'PUT' , {
10
6
data : {
@@ -27,14 +23,6 @@ export default ApplicationAdapter.extend({
27
23
} ) ;
28
24
} ,
29
25
30
- unfollow ( id ) {
31
- return this . ajax ( this . urlForFollowAction ( id ) , 'DELETE' ) ;
32
- } ,
33
-
34
- urlForFollowAction ( id ) {
35
- return `${ this . buildURL ( 'crate' , id ) } /follow` ;
36
- } ,
37
-
38
26
urlForOwnerAction ( id ) {
39
27
return `${ this . buildURL ( 'crate' , id ) } /owners` ;
40
28
} ,
Original file line number Diff line number Diff line change 1
1
import Model , { attr , hasMany } from '@ember-data/model' ;
2
2
import { map , sort } from '@ember/object/computed' ;
3
3
4
+ import { memberAction } from 'ember-api-actions' ;
5
+
4
6
export default Model . extend ( {
5
7
name : attr ( 'string' ) ,
6
8
downloads : attr ( 'number' ) ,
@@ -38,9 +40,8 @@ export default Model.extend({
38
40
categories : hasMany ( 'categories' , { async : true } ) ,
39
41
reverse_dependencies : hasMany ( 'dependency' , { async : true } ) ,
40
42
41
- follow ( ) {
42
- return this . store . adapterFor ( 'crate' ) . follow ( this . id ) ;
43
- } ,
43
+ follow : memberAction ( { type : 'PUT' , path : 'follow' } ) ,
44
+ unfollow : memberAction ( { type : 'DELETE' , path : 'follow' } ) ,
44
45
45
46
inviteOwner ( username ) {
46
47
return this . store . adapterFor ( 'crate' ) . inviteOwner ( this . id , username ) ;
@@ -49,8 +50,4 @@ export default Model.extend({
49
50
removeOwner ( username ) {
50
51
return this . store . adapterFor ( 'crate' ) . removeOwner ( this . id , username ) ;
51
52
} ,
52
-
53
- unfollow ( ) {
54
- return this . store . adapterFor ( 'crate' ) . unfollow ( this . id ) ;
55
- } ,
56
53
} ) ;
You can’t perform that action at this time.
0 commit comments