diff options
author | Bernhard Posselt <dev@bernhard-posselt.com> | 2014-04-09 16:52:04 +0200 |
---|---|---|
committer | Bernhard Posselt <dev@bernhard-posselt.com> | 2014-04-09 22:52:27 +0200 |
commit | 3b5d012b57774420049408b96aa64282f0d34609 (patch) | |
tree | ac43b03d4b4c0df0e6158e6fa33f329ec831205d /js/app/services | |
parent | 6e0de4208c06a3c95cbe274a93476b6b7eacafa0 (diff) |
fix user settings request
Diffstat (limited to 'js/app/services')
-rw-r--r-- | js/app/services/persistence.coffee | 80 |
1 files changed, 25 insertions, 55 deletions
diff --git a/js/app/services/persistence.coffee b/js/app/services/persistence.coffee index bd44d15d1..cdd389909 100644 --- a/js/app/services/persistence.coffee +++ b/js/app/services/persistence.coffee @@ -37,19 +37,21 @@ $rootScope, $q) -> ### Loads the initial data from the server ### - + successCount = 0 @deferred = $q.defer() @getAllFolders() successCallback = => - @deferred.resolve() + if successCount == 1 + @deferred.resolve() + else + successCount++ @getAllFeeds(successCallback) - @userSettingsRead() - @userSettingsLanguage() - @userSettingsIsCompact() + @getSettings(successCallback) + # items can only be loaded after the active feed is known @getActiveFeed => @@ -442,34 +444,13 @@ $rootScope, $q) -> ### USERSETTINGS CONTROLLER ### - userSettingsRead: (onSuccess=null) -> - ### - Gets the configs for read settings - ### - onSuccess or= -> - - # loading sign handling - @_feedLoading.increase() - successCallbackWrapper = (data) => - onSuccess() - @_feedLoading.decrease() - failureCallbackWrapper = (data) => - @_feedLoading.decrease() - - params = - onSuccess: successCallbackWrapper - onFailure: failureCallbackWrapper - - @_request.get '/apps/news/usersettings/read', params - - userSettingsReadShow: (callback) -> ### Sets the reader mode to show all ### data = - onSuccess: callback - @_request.post '/apps/news/usersettings/read/show', data + showAll: true + @setSettings data, callback userSettingsReadHide: (callback) -> @@ -477,41 +458,30 @@ $rootScope, $q) -> Sets the reader mode to show only unread ### data = - onSuccess: callback - @_request.post '/apps/news/usersettings/read/hide', data - - - userSettingsLanguage: (onSuccess=null) -> - onSuccess or= -> + showAll: false + @setSettings data, callback - # loading sign handling - @_feedLoading.increase() - successCallbackWrapper = (data) => - onSuccess() - @_feedLoading.decrease() - failureCallbackWrapper = (data) => - @_feedLoading.decrease() + userSettingsSetCompact: (isCompact) -> + ### + sets all items of a folder as read + ### data = - onSuccess: successCallbackWrapper - onFailure: failureCallbackWrapper - - @_request.get '/apps/news/usersettings/language', data + compact: isCompact + @setSettings data - userSettingsIsCompact: -> - @_request.get '/apps/news/usersettings/compact' + setSettings: (settings, onSuccess) -> + onSuccess or= -> + data = + onSuccess: onSuccess + data: settings + @_request.post '/apps/news/settings', data - userSettingsSetCompact: (isCompact) -> - ### - sets all items of a folder as read - ### - params = - data: - compact: isCompact - @_request.post '/apps/news/usersettings/compact', params + getSettings: -> + @_request.get '/apps/news/settings' _triggerHideRead: -> |