summaryrefslogtreecommitdiffstats
path: root/js
diff options
context:
space:
mode:
authorBernhard Posselt <nukeawhale@gmail.com>2013-05-10 13:30:00 +0200
committerBernhard Posselt <nukeawhale@gmail.com>2013-05-10 13:30:00 +0200
commit347000cc2d5597c1971942ebdbe97461c9fa5802 (patch)
tree8a2f6dc166ad871c646b4cf8bf13f4a9fcd02e55 /js
parentc487bfe23312a5b266d8eb21a3825ab791a1c3e8 (diff)
use a deleted flag for deleted feeds to handle undo
Diffstat (limited to 'js')
-rw-r--r--js/app/services/businesslayer/folderbusinesslayer.coffee20
-rw-r--r--js/app/services/undoqueue.coffee4
-rw-r--r--js/public/app.js34
3 files changed, 27 insertions, 31 deletions
diff --git a/js/app/services/businesslayer/folderbusinesslayer.coffee b/js/app/services/businesslayer/folderbusinesslayer.coffee
index 39c307c96..3d1fbb7c7 100644
--- a/js/app/services/businesslayer/folderbusinesslayer.coffee
+++ b/js/app/services/businesslayer/folderbusinesslayer.coffee
@@ -43,11 +43,12 @@ NewestItem, FeedModel) ->
delete: (folderId) ->
feeds = []
- folder = @_folderModel.removeById(folderId)
-
# also delete feeds
for feed in @_feedBusinessLayer.getFeedsOfFolder(folderId)
feeds.push(@_feedModel.removeById(feed.id))
+
+ folder = @_folderModel.removeById(folderId)
+
callback = =>
@_persistence.deleteFolder(folderId)
@@ -159,8 +160,8 @@ NewestItem, FeedModel) ->
_importElement: (opml, parentFolderId) ->
for item in opml.getItems()
- if item.isFolder()
- do (item) =>
+ do (item) =>
+ if item.isFolder()
try
@create item.getName(), (data) =>
@_importElement(item, data.folders[0].id)
@@ -171,14 +172,13 @@ NewestItem, FeedModel) ->
@_importElement(item, folder.id)
else
console.info error
- else
- try
- do (item) =>
+ else
+ try
@_feedBusinessLayer.create(item.getUrl(),
parentFolderId)
- catch error
- if not error instanceof _ExistsError
- console.info error
+ catch error
+ if not error instanceof _ExistsError
+ console.info error
return new FolderBusinessLayer(FolderModel, FeedBusinessLayer, ShowAll,
diff --git a/js/app/services/undoqueue.coffee b/js/app/services/undoqueue.coffee
index 93f6fb577..631013d13 100644
--- a/js/app/services/undoqueue.coffee
+++ b/js/app/services/undoqueue.coffee
@@ -44,7 +44,7 @@ angular.module('News').factory 'UndoQueue',
an command has been canceled. Usually this will add back a deleted
object back to the interface, defaults to an empty function
###
- @_executeAll()
+ @executeAll()
command =
_undoCallback: @_undoCallback or= ->
@@ -70,7 +70,7 @@ angular.module('News').factory 'UndoQueue',
@_queue.push(command)
- _executeAll: ->
+ executeAll: ->
###
Executes the callback before the timeout has run out
This is useful to execute all remaining commands if a new command is
diff --git a/js/public/app.js b/js/public/app.js
index 8329f90f6..df5202f88 100644
--- a/js/public/app.js
+++ b/js/public/app.js
@@ -1076,12 +1076,12 @@ License along with this library. If not, see <http://www.gnu.org/licenses/>.
_this = this;
feeds = [];
- folder = this._folderModel.removeById(folderId);
_ref = this._feedBusinessLayer.getFeedsOfFolder(folderId);
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
feed = _ref[_i];
feeds.push(this._feedModel.removeById(feed.id));
}
+ folder = this._folderModel.removeById(folderId);
callback = function() {
return _this._persistence.deleteFolder(folderId);
};
@@ -1228,17 +1228,17 @@ License along with this library. If not, see <http://www.gnu.org/licenses/>.
};
FolderBusinessLayer.prototype._importElement = function(opml, parentFolderId) {
- var error, item, _i, _len, _ref, _results,
+ var item, _i, _len, _ref, _results,
_this = this;
_ref = opml.getItems();
_results = [];
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
item = _ref[_i];
- if (item.isFolder()) {
- _results.push((function(item) {
- var error, folder;
+ _results.push((function(item) {
+ var error, folder;
+ if (item.isFolder()) {
try {
return _this.create(item.getName(), function(data) {
return _this._importElement(item, data.folders[0].id);
@@ -1253,21 +1253,17 @@ License along with this library. If not, see <http://www.gnu.org/licenses/>.
return console.info(error);
}
}
- })(item));
- } else {
- try {
- _results.push((function(item) {
+ } else {
+ try {
return _this._feedBusinessLayer.create(item.getUrl(), parentFolderId);
- })(item));
- } catch (_error) {
- error = _error;
- if (!error instanceof _ExistsError) {
- _results.push(console.info(error));
- } else {
- _results.push(void 0);
+ } catch (_error) {
+ error = _error;
+ if (!error instanceof _ExistsError) {
+ return console.info(error);
+ }
}
}
- }
+ })(item));
}
return _results;
};
@@ -3234,7 +3230,7 @@ License along with this library. If not, see <http://www.gnu.org/licenses/>.
object back to the interface, defaults to an empty function
*/
- this._executeAll();
+ this.executeAll();
command = {
_undoCallback: this._undoCallback || (this._undoCallback = function() {}),
_callback: this._callback,
@@ -3260,7 +3256,7 @@ License along with this library. If not, see <http://www.gnu.org/licenses/>.
return this._queue.push(command);
};
- UndoQueue.prototype._executeAll = function() {
+ UndoQueue.prototype.executeAll = function() {
/*
Executes the callback before the timeout has run out
This is useful to execute all remaining commands if a new command is