diff --git a/pxtlib/tilemap.ts b/pxtlib/tilemap.ts index 653bdf328699..cee08e6eb02b 100644 --- a/pxtlib/tilemap.ts +++ b/pxtlib/tilemap.ts @@ -1240,14 +1240,11 @@ namespace pxt { } function cleanupCollection(collection: AssetCollection) { - const inactiveAssets = collection.getSnapshot(asset => !asset.meta.displayName && asset.meta.blockIDs?.some(id => activeBlockIDs.indexOf(id) === -1)); + const inactiveAssets = collection.getSnapshot(asset => asset.meta.blockIDs?.some(id => activeBlockIDs.indexOf(id) === -1)); const toRemove: Asset[] = []; for (const asset of inactiveAssets) { - if (asset.meta.blockIDs.length === 1) toRemove.push(asset) - else { - asset.meta.blockIDs = asset.meta.blockIDs.filter(id => activeBlockIDs.indexOf(id) !== -1); - if (asset.meta.blockIDs.length === 0) toRemove.push(asset); - } + asset.meta.blockIDs = asset.meta.blockIDs.filter(id => activeBlockIDs.indexOf(id) !== -1); + if (!asset.meta.displayName && asset.meta.blockIDs.length === 0) toRemove.push(asset); } for (const asset of toRemove) { collection.removeByID(asset.id); diff --git a/webapp/src/components/assetEditor/assetSidebar.tsx b/webapp/src/components/assetEditor/assetSidebar.tsx index 7e557156876f..424be125cb4c 100644 --- a/webapp/src/components/assetEditor/assetSidebar.tsx +++ b/webapp/src/components/assetEditor/assetSidebar.tsx @@ -54,6 +54,10 @@ class AssetSidebarImpl extends React.Component block.id)); + } const canDelete = !isGalleryAsset && !project.isAssetUsed(asset, pkg.mainEditorPkg().files); this.setState({ canEdit, canCopy, canDelete });