From 82efc42a1384a3996012f0354326d1aec61e0df1 Mon Sep 17 00:00:00 2001 From: DD Date: Fri, 13 Oct 2017 17:35:56 -0400 Subject: [PATCH] Update storage when the SVG updates --- src/virtual-machine.js | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/virtual-machine.js b/src/virtual-machine.js index eec4d0752..6f0658414 100644 --- a/src/virtual-machine.js +++ b/src/virtual-machine.js @@ -400,9 +400,13 @@ class VirtualMachine extends EventEmitter { costume.rotationCenterY = rotationCenterY; this.runtime.renderer.updateSVGSkin(costume.skinId, svg, [rotationCenterX, rotationCenterY]); } - // @todo: Also update storage in addition to renderer. Without storage, if you switch - // costumes and switch back, you will lose your changes in the paint editor. - // @todo: emitTargetsUpdate if we need to update the storage ID on the updated costume. + const storage = this.runtime.storage; + costume.assetId = storage.builtinHelper.cache( + storage.AssetType.ImageVector, + storage.DataFormat.SVG, + (new TextEncoder()).encode(svg) + ); + this.emitTargetsUpdate(); } /**