Skip to content

Commit 93e6a9b

Browse files
committed
models/crate: Use memberAction() for invite|removeOwner() implementations
1 parent e85b672 commit 93e6a9b

File tree

2 files changed

+21
-35
lines changed

2 files changed

+21
-35
lines changed

app/adapters/crate.js

Lines changed: 0 additions & 29 deletions
This file was deleted.

app/models/crate.js

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,26 @@ export default Model.extend({
4343
follow: memberAction({ type: 'PUT', path: 'follow' }),
4444
unfollow: memberAction({ type: 'DELETE', path: 'follow' }),
4545

46-
inviteOwner(username) {
47-
return this.store.adapterFor('crate').inviteOwner(this.id, username);
48-
},
46+
inviteOwner: memberAction({
47+
type: 'PUT',
48+
path: 'owners',
49+
before(username) {
50+
return { owners: [username] };
51+
},
52+
after(response) {
53+
if (response.ok) {
54+
return response;
55+
} else {
56+
throw response;
57+
}
58+
},
59+
}),
4960

50-
removeOwner(username) {
51-
return this.store.adapterFor('crate').removeOwner(this.id, username);
52-
},
61+
removeOwner: memberAction({
62+
type: 'DELETE',
63+
path: 'owners',
64+
before(username) {
65+
return { owners: [username] };
66+
},
67+
}),
5368
});

0 commit comments

Comments
 (0)