From a765f52f8a5330c990ef310f9c14b1b48b49c9d2 Mon Sep 17 00:00:00 2001 From: Rolux Date: Fri, 8 Jan 2016 09:41:22 +0530 Subject: [PATCH] fix double reloading of lists --- static/js/list.js | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/static/js/list.js b/static/js/list.js index ba7d44e..e5001e9 100644 --- a/static/js/list.js +++ b/static/js/list.js @@ -97,7 +97,11 @@ oml.ui.list = function() { }, paste: function(data) { var items = oml.clipboard.paste(); - if (items.length && oml.clipboard.type() == 'book' && oml.getListData().editable) { + if ( + items.length + && oml.clipboard.type() == 'book' + && oml.getListData().editable + ) { oml.doHistory('paste', items, ui._list, function() { oml.UI.set({listSelection: items}); oml.reloadList(); @@ -113,16 +117,18 @@ oml.ui.list = function() { }, oml_find: function() { if (ui.listView == oml.UI.getPrevious().listView) { - if (JSON.stringify(ui.listSort) == JSON.stringify(oml.UI.getPrevious().listSort)) { - that.reloadList(); - } else { - //fixme: this reloads list twice. - //just setting sort will not update number of items - that.options({ - sort: Ox.clone(ui.listSort, true) - }); - that.reloadList(); + if ( + JSON.stringify(ui.listSort) + != JSON.stringify(oml.UI.getPrevious().listSort) + ) { + /* + that.options({sort: ...}) would already reload + the list, but not update the number of items + */ + var options = that.options(); + options.sort = Ox.clone(ui.listSort, true); } + that.reloadList(); } }, oml_item: function() {