Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 3 additions & 6 deletions pxtlib/tilemap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1240,14 +1240,11 @@ namespace pxt {
}

function cleanupCollection<U extends Asset>(collection: AssetCollection<U>) {
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);
Expand Down
4 changes: 4 additions & 0 deletions webapp/src/components/assetEditor/assetSidebar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,10 @@ class AssetSidebarImpl extends React.Component<AssetSidebarProps, AssetSidebarSt
const project = pxt.react.getTilemapProject();
const canEdit = !isGalleryAsset;
const canCopy = asset?.type != pxt.AssetType.Tilemap && asset?.type != pxt.AssetType.Animation;
const blocksEditor = getBlocksEditor();
if (blocksEditor?.editor) {
project.removeInactiveBlockAssets(blocksEditor.editor.getAllBlocks(false).map(block => block.id));
}
const canDelete = !isGalleryAsset && !project.isAssetUsed(asset, pkg.mainEditorPkg().files);

this.setState({ canEdit, canCopy, canDelete });
Expand Down