summaryrefslogtreecommitdiffstats
path: root/js
diff options
context:
space:
mode:
authorBernhard Posselt <nukeawhale@gmail.com>2013-04-20 16:11:56 +0200
committerBernhard Posselt <nukeawhale@gmail.com>2013-04-20 16:11:56 +0200
commit43448880561846bf0c71f0b8836500a3cb8017c9 (patch)
tree0ec1e354f1662782e355d3c07cc6a9a0523bec2d /js
parentf15d7d26e51503edc4a41edfdddee92a2aff8a19 (diff)
update all feeds in one go and dont trigger serverside update anymore on feedupdate, fix #90
Diffstat (limited to 'js')
-rw-r--r--js/app/app.coffee8
-rw-r--r--js/app/services/businesslayer/feedbusinesslayer.coffee6
-rw-r--r--js/app/services/persistence.coffee19
-rw-r--r--js/public/app.js50
-rw-r--r--js/tests/services/businesslayer/feedbusinesslayerSpec.coffee18
-rw-r--r--js/tests/services/persistenceSpec.coffee11
6 files changed, 49 insertions, 63 deletions
diff --git a/js/app/app.coffee b/js/app/app.coffee
index 264078b57..bf2ab08ec 100644
--- a/js/app/app.coffee
+++ b/js/app/app.coffee
@@ -26,7 +26,7 @@ angular.module('News', ['OC', 'ui']).config ($provide) ->
$provide.value 'Config', config =
markReadTimeout: 500
scrollTimeout: 500
- feedUpdateInterval: 600000
+ feedUpdateInterval: 1000*60*10
itemBatchSize: 20
# the autoPageFactor defines how many heights of the box must be left
# before it starts autopaging e.g. if it was 2, then it will start
@@ -34,13 +34,13 @@ angular.module('News', ['OC', 'ui']).config ($provide) ->
autoPageFactor: 6
-angular.module('News').run ['Persistence', 'Config', 'FeedBusinessLayer',
-(Persistence, Config, FeedBusinessLayer) ->
+angular.module('News').run ['Persistence', 'Config',
+(Persistence, Config) ->
Persistence.init()
setInterval ->
- FeedBusinessLayer.updateFeeds()
+ Persistence.getAllFeeds()
, Config.feedUpdateInterval
]
diff --git a/js/app/services/businesslayer/feedbusinesslayer.coffee b/js/app/services/businesslayer/feedbusinesslayer.coffee
index a2fa0df3e..0ad81d875 100644
--- a/js/app/services/businesslayer/feedbusinesslayer.coffee
+++ b/js/app/services/businesslayer/feedbusinesslayer.coffee
@@ -166,12 +166,6 @@ FeedModel, NewLoading, _ExistsError, Utils) ->
@_feedModel.removeByUrl(url)
- updateFeeds: ->
- for feed in @_feedModel.getAll()
- if angular.isDefined(feed.id)
- @_persistence.updateFeed(feed.id)
-
-
importGoogleReader: (json) ->
url = 'http://owncloud/googlereader' # hardcoded
diff --git a/js/app/services/persistence.coffee b/js/app/services/persistence.coffee
index 88d1d18cc..a5a6bc092 100644
--- a/js/app/services/persistence.coffee
+++ b/js/app/services/persistence.coffee
@@ -156,16 +156,21 @@ $rootScope) ->
###
FEED CONTROLLER
###
- getAllFeeds: (onSuccess) ->
+ getAllFeeds: (onSuccess, showLoading=true) ->
onSuccess or= ->
# loading sign handling
- @_feedLoading.increase()
- successCallbackWrapper = (data) =>
- onSuccess()
- @_feedLoading.decrease()
- failureCallbackWrapper = (data) =>
- @_feedLoading.decrease()
+ if showLoading
+ @_feedLoading.increase()
+ successCallbackWrapper = (data) =>
+ onSuccess()
+ @_feedLoading.decrease()
+ failureCallbackWrapper = (data) =>
+ @_feedLoading.decrease()
+ else
+ successCallbackWrapper = (data) =>
+ onSuccess()
+ failureCallbackWrapper = (data) =>
params =
onSuccess: successCallbackWrapper
diff --git a/js/public/app.js b/js/public/app.js
index 7422fc83a..10f9b4a7b 100644
--- a/js/public/app.js
+++ b/js/public/app.js
@@ -41,17 +41,17 @@ License along with this library. If not, see <http://www.gnu.org/licenses/>.
return $provide.value('Config', config = {
markReadTimeout: 500,
scrollTimeout: 500,
- feedUpdateInterval: 600000,
+ feedUpdateInterval: 1000 * 60 * 10,
itemBatchSize: 20,
autoPageFactor: 6
});
});
angular.module('News').run([
- 'Persistence', 'Config', 'FeedBusinessLayer', function(Persistence, Config, FeedBusinessLayer) {
+ 'Persistence', 'Config', function(Persistence, Config) {
Persistence.init();
return setInterval(function() {
- return FeedBusinessLayer.updateFeeds();
+ return Persistence.getAllFeeds();
}, Config.feedUpdateInterval);
}
]);
@@ -896,22 +896,6 @@ License along with this library. If not, see <http://www.gnu.org/licenses/>.
return this._feedModel.removeByUrl(url);
};
- FeedBusinessLayer.prototype.updateFeeds = function() {
- var feed, _i, _len, _ref, _results;
-
- _ref = this._feedModel.getAll();
- _results = [];
- for (_i = 0, _len = _ref.length; _i < _len; _i++) {
- feed = _ref[_i];
- if (angular.isDefined(feed.id)) {
- _results.push(this._persistence.updateFeed(feed.id));
- } else {
- _results.push(void 0);
- }
- }
- return _results;
- };
-
FeedBusinessLayer.prototype.importGoogleReader = function(json) {
var feed, url;
@@ -2424,19 +2408,29 @@ License along with this library. If not, see <http://www.gnu.org/licenses/>.
*/
- Persistence.prototype.getAllFeeds = function(onSuccess) {
+ Persistence.prototype.getAllFeeds = function(onSuccess, showLoading) {
var failureCallbackWrapper, params, successCallbackWrapper,
_this = this;
+ if (showLoading == null) {
+ showLoading = true;
+ }
onSuccess || (onSuccess = function() {});
- this._feedLoading.increase();
- successCallbackWrapper = function(data) {
- onSuccess();
- return _this._feedLoading.decrease();
- };
- failureCallbackWrapper = function(data) {
- return _this._feedLoading.decrease();
- };
+ if (showLoading) {
+ this._feedLoading.increase();
+ successCallbackWrapper = function(data) {
+ onSuccess();
+ return _this._feedLoading.decrease();
+ };
+ failureCallbackWrapper = function(data) {
+ return _this._feedLoading.decrease();
+ };
+ } else {
+ successCallbackWrapper = function(data) {
+ return onSuccess();
+ };
+ failureCallbackWrapper = function(data) {};
+ }
params = {
onSuccess: successCallbackWrapper,
onFailure: failureCallbackWrapper
diff --git a/js/tests/services/businesslayer/feedbusinesslayerSpec.coffee b/js/tests/services/businesslayer/feedbusinesslayerSpec.coffee
index 5ac93f25e..d14d50b8d 100644
--- a/js/tests/services/businesslayer/feedbusinesslayerSpec.coffee
+++ b/js/tests/services/businesslayer/feedbusinesslayerSpec.coffee
@@ -329,24 +329,6 @@ describe 'FeedBusinessLayer', ->
expect(@FeedModel.getByUrl('john')).toBe(undefined)
- it 'should update all feeds', =>
- @persistence.updateFeed = jasmine.createSpy('update')
- @FeedModel.add({id: 3, url: 'john'})
-
- @FeedBusinessLayer.updateFeeds()
-
- expect(@persistence.updateFeed).toHaveBeenCalledWith(3)
-
-
- it 'should not update feeds without ids', =>
- @persistence.updateFeed = jasmine.createSpy('update')
- @FeedModel.add({url: 'john'})
-
- @FeedBusinessLayer.updateFeeds()
-
- expect(@persistence.updateFeed).not.toHaveBeenCalled()
-
-
it 'should not import google reader json', =>
@persistence.importGoogleReader = jasmine.createSpy('importGoogleReader')
diff --git a/js/tests/services/persistenceSpec.coffee b/js/tests/services/persistenceSpec.coffee
index 98bd96531..70bcf824f 100644
--- a/js/tests/services/persistenceSpec.coffee
+++ b/js/tests/services/persistenceSpec.coffee
@@ -32,8 +32,13 @@ describe 'Persistence', ->
@config =
itemBatchSize: 3
+ @feedLoading =
+ increase: jasmine.createSpy('feedLoading increase')
+ decrease: jasmine.createSpy('feedLoading decrease')
+
$provide.value 'Request', @req
$provide.value 'Config', @config
+ $provide.value 'FeedLoading', @feedLoading
return
@@ -165,6 +170,12 @@ describe 'Persistence', ->
expect(@req.get).toHaveBeenCalledWith('news_feeds', expected)
+ it 'should not show loading sign if disabled', =>
+ success = ->
+ @Persistence.getAllFeeds(success, false)
+ expect(@feedLoading.increase).not.toHaveBeenCalled()
+
+
it 'create a correct request for moving a feed', =>
params =
data: