summaryrefslogtreecommitdiffstats
path: root/js/controller
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/controller
parent320304c909dc12c14b53335a7f32550809c06178 (diff)
add autopaging
Diffstat (limited to 'js/controller')
-rw-r--r--js/controller/ContentController.js54
1 files changed, 40 insertions, 14 deletions
diff --git a/js/controller/ContentController.js b/js/controller/ContentController.js
index 804c898e5..5a75f68ab 100644
--- a/js/controller/ContentController.js
+++ b/js/controller/ContentController.js
@@ -8,7 +8,8 @@
* @copyright Bernhard Posselt 2014
*/
app.controller('ContentController',
-function (Publisher, FeedResource, ItemResource, SettingsResource, data) {
+function (Publisher, FeedResource, ItemResource, SettingsResource, data,
+ $route, $routeParams) {
'use strict';
this.isAutoPagingEnabled = true;
@@ -27,10 +28,12 @@ function (Publisher, FeedResource, ItemResource, SettingsResource, data) {
};
this.markRead = (itemId) => {
- ItemResource.markItemRead(itemId);
-
let item = ItemResource.get(itemId);
- FeedResource.markItemOfFeedRead(item.feedId);
+
+ if (!item.keepUnread) {
+ ItemResource.markItemRead(itemId);
+ FeedResource.markItemOfFeedRead(item.feedId);
+ }
};
this.getFeed = (feedId) => {
@@ -59,25 +62,48 @@ function (Publisher, FeedResource, ItemResource, SettingsResource, data) {
return SettingsResource.get('compact');
};
- // TBD
- this.getRelativeDate = (timestamp) => {
- console.log(timestamp);
+ this.autoPagingEnabled = () => {
+ return this.isAutoPagingEnabled;
};
- this.autoPage = () => {
- console.log('hi');
+ this.markReadEnabled = () => {
+ return !SettingsResource.get('preventReadOnScroll');
};
this.scrollRead = (itemIds) => {
- console.log(itemIds);
+ let ids = [];
+
+ for (let itemId of itemIds) {
+ let item = ItemResource.get(itemId);
+ if (!item.keepUnread) {
+ ids.push(itemId);
+ FeedResource.markItemOfFeedRead(item.feedId);
+ }
+ }
+
+ ItemResource.markItemsRead(ids);
};
- this.autoPagingEnabled = () => {
- return this.isAutoPagingEnabled;
+ this.autoPage = () => {
+ this.isAutoPagingEnabled = false;
+
+ let type = $route.current.$$route.type;
+ let id = $routeParams.id;
+
+ ItemResource.autoPage(type, id).success((data) => {
+ Publisher.publishAll(data);
+
+ if (data.items.length > 0) {
+ this.isAutoPagingEnabled = true;
+ }
+ }).error(() => {
+ this.isAutoPagingEnabled = true;
+ });
};
- this.markReadEnabled = () => {
- return !SettingsResource.get('preventReadOnScroll');
+ // TBD
+ this.getRelativeDate = (timestamp) => {
+ console.log(timestamp);
};
}); \ No newline at end of file