From 05fa6cad3eff865fe2887b5fd57e5cd44dd52760 Mon Sep 17 00:00:00 2001 From: Karishma Chadha Date: Mon, 16 May 2022 16:24:10 -0400 Subject: [PATCH] Update handleLoadCostumeError to properly handle bitmap costumes --- src/import/load-costume.js | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/import/load-costume.js b/src/import/load-costume.js index 58f3cacf9..0bf6ba653 100644 --- a/src/import/load-costume.js +++ b/src/import/load-costume.js @@ -256,14 +256,18 @@ const handleCostumeLoadError = function (costume, runtime) { const oldAssetId = costume.assetId; const oldRotationX = costume.rotationCenterX; const oldRotationY = costume.rotationCenterY; - - // Use default asset if original fails to load - costume.assetId = runtime.storage.defaultAssetId.ImageVector; - costume.asset = runtime.storage.get(costume.assetId); - costume.md5 = `${costume.assetId}.${costume.dataFormat}`; const AssetType = runtime.storage.AssetType; - const defaultCostumePromise = (costume.dataFormat === AssetType.ImageVector.runtimeFormat) ? + const isVector = costume.dataFormat === AssetType.ImageVector.runtimeFormat; + + // Use default asset if original fails to load + costume.assetId = isVector ? + runtime.storage.defaultAssetId.ImageVector : + runtime.storage.defaultAssetId.ImageBitmap; + costume.asset = runtime.storage.get(costume.assetId); + costume.md5 = `${costume.assetId}.${costume.dataFormat}`; + + const defaultCostumePromise = (isVector) ? loadVector_(costume, runtime) : loadBitmap_(costume, runtime); return defaultCostumePromise.then(loadedCostume => {