Keep a Data Library entry whose layer fails to tear down

Remove dropped an entry from the selection and reported success even
when the manager could not disable or destroy its layer, leaving a
registered, possibly visible layer that Browse, share links and saved
state no longer knew. Remove now keeps the entry and reports failure,
so its row and Remove all still reach it and a later Remove can retry.
This commit is contained in:
Sameh Khamis committed 2026-11-12 15:57:02 -08:00
1 parent f33a6ada52
commit 53f0a32a1b
2 files changed
+48 -2

No files matched your search

+7 -2
View File
@@ -325,8 +325,13 @@ export function createDataLibrary({
async function remove(id) {
if (destroyed || pending.has(id)) return false;
const work = (async () => {
if (isRegistered(id))
await dataManager.unregisterLibraryLayer(libraryLayerId(id));
// A layer that would not tear down is still there: keep it in the
// library so its row, Remove and Remove all still reach it.
if (
isRegistered(id) &&
!(await dataManager.unregisterLibraryLayer(libraryLayerId(id)))
)
return false;
selection = {
added: selection.added.filter((other) => other !== id),
on: selection.on.filter((other) => other !== id),