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/public | |
parent | 6e0de4208c06a3c95cbe274a93476b6b7eacafa0 (diff) |
fix user settings request
Diffstat (limited to 'js/public')
-rw-r--r-- | js/public/app.js | 97 |
1 files changed, 31 insertions, 66 deletions
diff --git a/js/public/app.js b/js/public/app.js index 49c88e11c..8aac72b38 100644 --- a/js/public/app.js +++ b/js/public/app.js @@ -1,3 +1,4 @@ + /** * ownCloud News App - v0.0.1 * @@ -3386,17 +3387,20 @@ License along with this library. If not, see <http://www.gnu.org/licenses/>. Loads the initial data from the server */ - var successCallback, + var successCallback, successCount, _this = this; + successCount = 0; this.deferred = $q.defer(); this.getAllFolders(); successCallback = function() { - return _this.deferred.resolve(); + if (successCount === 1) { + return _this.deferred.resolve(); + } else { + return successCount++; + } }; this.getAllFeeds(successCallback); - this.userSettingsRead(); - this.userSettingsLanguage(); - this.userSettingsIsCompact(); + this.getSettings(successCallback); this.getActiveFeed(function() { return _this.getItems(_this._activeFeed.getType(), _this._activeFeed.getId()); }); @@ -3890,94 +3894,54 @@ License along with this library. If not, see <http://www.gnu.org/licenses/>. */ - Persistence.prototype.userSettingsRead = function(onSuccess) { - var failureCallbackWrapper, params, successCallbackWrapper, - _this = this; - if (onSuccess == null) { - onSuccess = null; - } + Persistence.prototype.userSettingsReadShow = function(callback) { /* - Gets the configs for read settings + Sets the reader mode to show all */ - onSuccess || (onSuccess = function() {}); - this._feedLoading.increase(); - successCallbackWrapper = function(data) { - onSuccess(); - return _this._feedLoading.decrease(); - }; - failureCallbackWrapper = function(data) { - return _this._feedLoading.decrease(); - }; - params = { - onSuccess: successCallbackWrapper, - onFailure: failureCallbackWrapper + var data; + data = { + showAll: true }; - return this._request.get('/apps/news/usersettings/read', params); + return this.setSettings(data, callback); }; - Persistence.prototype.userSettingsReadShow = function(callback) { + Persistence.prototype.userSettingsReadHide = function(callback) { /* - Sets the reader mode to show all + Sets the reader mode to show only unread */ var data; data = { - onSuccess: callback + showAll: false }; - return this._request.post('/apps/news/usersettings/read/show', data); + return this.setSettings(data, callback); }; - Persistence.prototype.userSettingsReadHide = function(callback) { + Persistence.prototype.userSettingsSetCompact = function(isCompact) { /* - Sets the reader mode to show only unread + sets all items of a folder as read */ var data; data = { - onSuccess: callback + compact: isCompact }; - return this._request.post('/apps/news/usersettings/read/hide', data); + return this.setSettings(data); }; - Persistence.prototype.userSettingsLanguage = function(onSuccess) { - var data, failureCallbackWrapper, successCallbackWrapper, - _this = this; - if (onSuccess == null) { - onSuccess = null; - } + Persistence.prototype.setSettings = function(settings, onSuccess) { + var data; onSuccess || (onSuccess = function() {}); - this._feedLoading.increase(); - successCallbackWrapper = function(data) { - onSuccess(); - return _this._feedLoading.decrease(); - }; - failureCallbackWrapper = function(data) { - return _this._feedLoading.decrease(); - }; data = { - onSuccess: successCallbackWrapper, - onFailure: failureCallbackWrapper + onSuccess: onSuccess, + data: settings }; - return this._request.get('/apps/news/usersettings/language', data); + return this._request.post('/apps/news/settings', data); }; - Persistence.prototype.userSettingsIsCompact = function() { - return this._request.get('/apps/news/usersettings/compact'); - }; - - Persistence.prototype.userSettingsSetCompact = function(isCompact) { - /* - sets all items of a folder as read - */ - - var params; - params = { - data: { - compact: isCompact - } - }; - return this._request.post('/apps/news/usersettings/compact', params); + Persistence.prototype.getSettings = function() { + return this._request.get('/apps/news/settings'); }; Persistence.prototype._triggerHideRead = function() { @@ -5172,3 +5136,4 @@ License along with this library. If not, see <http://www.gnu.org/licenses/>. }); }).call(this); + |