diff options
author | Sean Molenaar <sean@seanmolenaar.eu> | 2019-02-24 11:40:29 +0100 |
---|---|---|
committer | Sean Molenaar <SMillerDev@users.noreply.github.com> | 2019-03-05 11:35:14 +0100 |
commit | 6a4e56e7274d85bcbd0e2dcde7a61d8f7a4397ec (patch) | |
tree | 5bafad374708f5542081592456869f6fa1226f86 /js/service | |
parent | 45474dc86232897199382327527c7de80ec99c1c (diff) |
Cleanup JS and prolong error notification
Diffstat (limited to 'js/service')
-rw-r--r-- | js/service/FeedResource.js | 8 | ||||
-rw-r--r-- | js/service/ItemResource.js | 81 | ||||
-rw-r--r-- | js/service/OPMLImporter.js | 3 | ||||
-rw-r--r-- | js/service/OPMLParser.js | 5 | ||||
-rw-r--r-- | js/service/Resource.js | 2 |
5 files changed, 46 insertions, 53 deletions
diff --git a/js/service/FeedResource.js b/js/service/FeedResource.js index bb1f30f3f..0ae7d2ad4 100644 --- a/js/service/FeedResource.js +++ b/js/service/FeedResource.js @@ -163,8 +163,7 @@ app.factory('FeedResource', function (Resource, $http, BASE_URL, $q) { }; - FeedResource.prototype.create = function (url, folderId, title, user, - password) { + FeedResource.prototype.create = function (url, folderId, title, user, password) { url = url.trim(); if (!url.startsWith('http')) { url = 'https://' + url; @@ -203,8 +202,7 @@ app.factory('FeedResource', function (Resource, $http, BASE_URL, $q) { }; - FeedResource.prototype.reversiblyDelete = function (id, updateCache, - isFolder) { + FeedResource.prototype.reversiblyDelete = function (id, updateCache, isFolder) { var feed = this.getById(id); // if a folder is deleted it does not have to trigger the delete @@ -329,7 +327,7 @@ app.factory('FeedResource', function (Resource, $http, BASE_URL, $q) { var feed = this.getById(feedId); if (feed) { - Object.keys(diff).forEach(function(key) { + Object.keys(diff).forEach(function (key) { feed[key] = diff[key]; }); var url = this.BASE_URL + '/feeds/' + feedId; diff --git a/js/service/ItemResource.js b/js/service/ItemResource.js index 159216797..fcfd2f28d 100644 --- a/js/service/ItemResource.js +++ b/js/service/ItemResource.js @@ -7,8 +7,7 @@ * @author Bernhard Posselt <dev@bernhard-posselt.com> * @copyright Bernhard Posselt 2014 */ -app.factory('ItemResource', function (Resource, $http, BASE_URL, - ITEM_BATCH_SIZE) { +app.factory('ItemResource', function (Resource, $http, BASE_URL, ITEM_BATCH_SIZE) { 'use strict'; var ItemResource = function ($http, BASE_URL, ITEM_BATCH_SIZE) { @@ -29,42 +28,41 @@ app.factory('ItemResource', function (Resource, $http, BASE_URL, ItemResource.prototype.receive = function (value, channel) { switch (channel) { - - case 'newestItemId': - this.newestItemId = value; - break; - - case 'starred': - this.starredCount = value; - break; - - default: - var self = this; - var importValues = []; - value.forEach(function (item) { - // initialize lowest and highest id - if (self.lowestId === 0) { - self.lowestId = item.id; - } - if (self.highestId === 0) { - self.highestId = item.id; - } - - if (item.id > self.highestId) { - self.highestId = item.id; - } - if (item.id < self.lowestId) { - self.lowestId = item.id; - } - - // filter out duplicates - if (self.fingerprints[item.fingerprint] === undefined) { - self.fingerprints[item.fingerprint] = true; - importValues.push(item); - } - }); - - Resource.prototype.receive.call(this, importValues, channel); + case 'newestItemId': + this.newestItemId = value; + break; + + case 'starred': + this.starredCount = value; + break; + + default: + var self = this; + var importValues = []; + value.forEach(function (item) { + // initialize lowest and highest id + if (self.lowestId === 0) { + self.lowestId = item.id; + } + if (self.highestId === 0) { + self.highestId = item.id; + } + + if (item.id > self.highestId) { + self.highestId = item.id; + } + if (item.id < self.lowestId) { + self.lowestId = item.id; + } + + // filter out duplicates + if (self.fingerprints[item.fingerprint] === undefined) { + self.fingerprints[item.fingerprint] = true; + importValues.push(item); + } + }); + + Resource.prototype.receive.call(this, importValues, channel); } }; @@ -135,7 +133,7 @@ app.factory('ItemResource', function (Resource, $http, BASE_URL, ItemResource.prototype.markItemsRead = function (itemIds) { var self = this; - itemIds.forEach(function(itemId) { + itemIds.forEach(function (itemId) { self.get(itemId).unread = false; }); @@ -183,8 +181,7 @@ app.factory('ItemResource', function (Resource, $http, BASE_URL, }; - ItemResource.prototype.autoPage = function (type, id, oldestFirst, - showAll, search) { + ItemResource.prototype.autoPage = function (type, id, oldestFirst, showAll, search) { var offset; if (oldestFirst) { @@ -216,7 +213,7 @@ app.factory('ItemResource', function (Resource, $http, BASE_URL, data: { json: json } - }).then(function(response) { + }).then(function (response) { return response.data; }); }; diff --git a/js/service/OPMLImporter.js b/js/service/OPMLImporter.js index 92c3c0bfb..b2b52bc4c 100644 --- a/js/service/OPMLImporter.js +++ b/js/service/OPMLImporter.js @@ -7,8 +7,7 @@ * @author Bernhard Posselt <dev@bernhard-posselt.com> * @copyright Bernhard Posselt 2014 */ -app.service('OPMLImporter', function (FeedResource, FolderResource, Publisher, - $q) { +app.service('OPMLImporter', function (FeedResource, FolderResource, Publisher, $q) { 'use strict'; var startFeedJob = function (queue) { var deferred = $q.defer(); diff --git a/js/service/OPMLParser.js b/js/service/OPMLParser.js index 4de08c42f..6752e1d1e 100644 --- a/js/service/OPMLParser.js +++ b/js/service/OPMLParser.js @@ -43,7 +43,6 @@ app.service('OPMLParser', function () { if (entry.type === 'feed') { root.feeds.push(entry); } else { - // only first level should append folders if (firstLevel) { recursivelyParse(outline.children('outline'), entry, false); @@ -57,8 +56,8 @@ app.service('OPMLParser', function () { return root; }; - this.parse = function (xml) { - xml = $.parseXML(xml); + this.parse = function (fileContent) { + var xml = $.parseXML(fileContent); var firstLevel = $(xml).find('body > outline'); var root = { diff --git a/js/service/Resource.js b/js/service/Resource.js index 70bf5b43c..b5be87cb7 100644 --- a/js/service/Resource.js +++ b/js/service/Resource.js @@ -55,7 +55,7 @@ app.factory('Resource', function () { Resource.prototype.delete = function (id) { // find index of object that should be deleted var self = this; - var deleteAtIndex = this.values.findIndex(function(element) { + var deleteAtIndex = this.values.findIndex(function (element) { return element[self.id] === id; }); |