diff --git a/style.css b/style.css index 56ec292..1de4d06 100644 --- a/style.css +++ b/style.css @@ -404,6 +404,10 @@ main { } } +.keep-only.useless { + visibility: hidden; +} + .group-subtitle { color: var(--muted); font-size: 13px; diff --git a/tab-duplicates.js b/tab-duplicates.js index 603fe95..f43fdfd 100644 --- a/tab-duplicates.js +++ b/tab-duplicates.js @@ -77,7 +77,7 @@ TABS.duplicates = (function() { onclick: function() { keepOnlyThis(group, bookmark); } }) ]); - rows.set(bookmark.id, { row: row, checkbox: checkbox }); + rows.set(bookmark.id, { row: row, checkbox: checkbox, group: group }); list.append(row); }); return element("section", { className: "group" }, [ @@ -120,6 +120,12 @@ TABS.duplicates = (function() { item.checkbox.checked = deleting; item.row.classList.toggle("deleting", deleting); item.row.querySelector(".tag").textContent = deleting ? "Delete" : "Keep"; + // "Keep only this" is useless when this copy is already the only + // one kept: hide it, keeping its space so that rows stay aligned + var alreadyOnly = !deleting && item.group.bookmarks.every(function(b) { + return b.id == id || selected.has(b.id); + }); + item.row.querySelector(".keep-only").classList.toggle("useless", alreadyOnly); }); }