Better handle group indexes when deleting a group
This commit is contained in:
parent
45f33631e9
commit
192692d96b
|
@ -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();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue