diff options
author | Bernhard Posselt <dev@bernhard-posselt.com> | 2014-05-22 02:50:55 +0200 |
---|---|---|
committer | Bernhard Posselt <dev@bernhard-posselt.com> | 2014-05-22 02:50:55 +0200 |
commit | 6b46f7b265e2086e06629cd5d8d3f6f6ec517b8b (patch) | |
tree | 2a5985cfa2ec9c65b877ca30cb3b475cfebd1ebb /js/service | |
parent | 23246ea3987d8a60d3ea344ca93d209d082c3337 (diff) |
increase starcount if starring
Diffstat (limited to 'js/service')
-rw-r--r-- | js/service/ItemResource.js | 24 |
1 files changed, 15 insertions, 9 deletions
diff --git a/js/service/ItemResource.js b/js/service/ItemResource.js index 33f3efc52..779355e0a 100644 --- a/js/service/ItemResource.js +++ b/js/service/ItemResource.js @@ -15,6 +15,7 @@ app.factory('ItemResource', (Resource, $http, BASE_URL) => { constructor ($http, BASE_URL) { super($http, BASE_URL); + this.starredCount = 0; } @@ -44,30 +45,35 @@ app.factory('ItemResource', (Resource, $http, BASE_URL) => { } - star (itemId, star=true) { - let item = this.get(itemId); - let base = this.BASE_URL; - let url = `${base}/items/${item.feedId}/${item.guidHash}/star`; + star (itemId, isStarred=true) { + let it = this.get(itemId); + let url = `${this.BASE_URL}/items/${it.feedId}/${it.guidHash}/star`; - item.starred = star; + it.starred = isStarred; + + if (isStarred) { + this.starredCount += 1; + } else { + this.starredCount -= 1; + } return this.http({ url: url, method: 'POST', data: { - isStarred: star + isStarred: isStarred } }); } - read (itemId, read=true) { - this.get(itemId).unread = !read; + read (itemId, isRead=true) { + this.get(itemId).unread = !isRead; return this.http({ url: `${this.BASE_URL}/items/${itemId}/read`, method: 'POST', data: { - isRead: read + isRead: isRead } }); } |