Better handle group indexes when deleting a group

This commit is contained in:
Neil Brommer 2017-12-27 16:01:12 -08:00
parent 45f33631e9
commit 192692d96b

View file

@ -80,9 +80,21 @@ function deleteGroup(e) {
var db = dbe.target.result; var db = dbe.target.result;
var groupsStore = db.transaction("Groups", "readwrite").objectStore("Groups"); var groupsStore = db.transaction("Groups", "readwrite").objectStore("Groups");
var delReq = groupsStore.delete(groupIndex);
delReq.onsuccess = function (dele) { groupsStore.getAll().onsuccess = function (getEvt) {
$("#group-" + groupIndex).remove(); var groups = getEvt.target.result;
var lastIndex = -1;
for (item of groups) {
if (item.groupIndex > groupIndex) {
lastIndex = item.groupIndex;
item.groupIndex--;
groupsStore.put(item);
}
}
groupsStore.delete(lastIndex);
loadBookmarks();
} }
} }