summaryrefslogtreecommitdiffstats
path: root/js/service
diff options
context:
space:
mode:
authorBernhard Posselt <dev@bernhard-posselt.com>2014-05-30 00:06:49 +0200
committerBernhard Posselt <dev@bernhard-posselt.com>2014-05-30 00:06:49 +0200
commit79032a17fb1f458aae723098ddc1a96c28daad05 (patch)
treeb7e7a7f99e6e334d9058de7445280da6624ec3e3 /js/service
parent320304c909dc12c14b53335a7f32550809c06178 (diff)
add autopaging
Diffstat (limited to 'js/service')
-rw-r--r--js/service/ItemResource.js36
1 files changed, 33 insertions, 3 deletions
diff --git a/js/service/ItemResource.js b/js/service/ItemResource.js
index 625f58b5e..f0bc0d485 100644
--- a/js/service/ItemResource.js
+++ b/js/service/ItemResource.js
@@ -7,15 +7,16 @@
* @author Bernhard Posselt <dev@bernhard-posselt.com>
* @copyright Bernhard Posselt 2014
*/
-app.factory('ItemResource', (Resource, $http, BASE_URL) => {
+app.factory('ItemResource', (Resource, $http, BASE_URL, ITEM_BATCH_SIZE) => {
'use strict';
class ItemResource extends Resource {
- constructor ($http, BASE_URL) {
+ constructor ($http, BASE_URL, ITEM_BATCH_SIZE) {
super($http, BASE_URL);
this.starredCount = 0;
+ this.batchSize = ITEM_BATCH_SIZE;
}
@@ -88,6 +89,21 @@ app.factory('ItemResource', (Resource, $http, BASE_URL) => {
}
+ markItemsRead (itemIds) {
+ for (let itemId of itemIds) {
+ this.get(itemId).unread = false;
+ }
+
+ return this.http({
+ url: `${this.BASE_URL}/items/read/multiple`,
+ method: 'POST',
+ data: {
+ itemIds: itemIds
+ }
+ });
+ }
+
+
markFeedRead (feedId, read=true) {
for (let item of this.values.filter(i => i.feedId === feedId)) {
item.unread = !read;
@@ -108,7 +124,21 @@ app.factory('ItemResource', (Resource, $http, BASE_URL) => {
super.clear();
}
+
+ autoPage (type, id) {
+ return this.http({
+ url: `${this.BASE_URL}/items`,
+ method: 'GET',
+ params: {
+ type: type,
+ id: id,
+ offset: this.size(),
+ limit: this.batchSize
+ }
+ });
+ }
+
}
- return new ItemResource($http, BASE_URL);
+ return new ItemResource($http, BASE_URL, ITEM_BATCH_SIZE);
}); \ No newline at end of file