diff options
Diffstat (limited to 'js/app/controllers')
-rw-r--r-- | js/app/controllers/feedcontroller.coffee | 33 |
1 files changed, 15 insertions, 18 deletions
diff --git a/js/app/controllers/feedcontroller.coffee b/js/app/controllers/feedcontroller.coffee index 0860cabc5..742693253 100644 --- a/js/app/controllers/feedcontroller.coffee +++ b/js/app/controllers/feedcontroller.coffee @@ -49,28 +49,25 @@ angular.module('News').factory '_FeedController', @_$scope.addFeed = (feedUrl, parentFolderId=0) => @_$scope.feedEmptyError = false - @_$scope.feedError = false + @_$scope.feedExistsError = false - if angular.isUndefined(feedUrl) or feedUrl.trim() == '' - @_$scope.feedEmptyError = true - - if not @_$scope.feedEmptyError + try @_isAddingFeed = true - - onError = => - @_$scope.feedError = true + @_feedBl.create feedUrl, parentFolderId + # on success + , => + @_$scope.feedUrl = '' + @_isAddingFeed = false + # on error + , => @_isAddingFeed = false - - onSuccess = (data) => - if data.status == 'error' - onError() - else - @_$scope.feedUrl = '' - @_isAddingFeed = false - - @_persistence.createFeed(feedUrl.trim(), parentFolderId, - onSuccess, onError) + catch error + if error instanceof _ExistsError + @_$scope.feedExistsError = true + else + @_$scope.feedEmptyError = true + @_$scope.addFolder = (folderName) => @_$scope.folderEmptyError = false |