Code clean up from code review

Co-authored-by: Christopher Willis-Ford <7019101+cwillisf@users.noreply.github.com>
This commit is contained in:
Karishma Chadha 2022-05-16 16:07:08 -04:00 committed by GitHub
parent 172409c1e3
commit fd31a777e2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 5 additions and 9 deletions

View file

@ -16,13 +16,9 @@ const serializeAssets = function (runtime, assetType, optTargetId) {
const currAssets = currTarget.sprite[assetType];
for (let j = 0; j < currAssets.length; j++) {
const currAsset = currAssets[j];
let asset = currAsset.asset;
if (currAsset.broken) {
if (currAsset.broken.asset) {
asset = currAsset.broken.asset;
} else {
continue;
}
const asset = currAsset.broken ? curAsset.broken.asset : currAsset.asset;
if (!asset) {
continue;
}
assetDescs.push({
fileName: `${asset.assetId}.${asset.dataFormat}`,

View file

@ -931,7 +931,7 @@ class VirtualMachine extends EventEmitter {
*/
updateSvg (costumeIndex, svg, rotationCenterX, rotationCenterY) {
const costume = this.editingTarget.getCostumes()[costumeIndex];
if (costume && costume.broken) costume.broken = null;
if (costume && costume.broken) delete costume.broken;
if (costume && this.runtime && this.runtime.renderer) {
costume.rotationCenterX = rotationCenterX;
costume.rotationCenterY = rotationCenterY;

View file

@ -15,7 +15,7 @@ module.exports = {
},
extractAsset: function (path, assetFileName) {
const zip = new AdmZip(path);
const assetEntry = zip.getEntries().filter(item => item.entryName.match(assetFileName))[0];
const assetEntry = zip.getEntries().find(item => item.entryName.match(assetFileName));
return assetEntry.getData();
}
};