@@ -1018,38 +1018,45 @@ namespace pxt {
10181018 const isProject = dep . id === "this" ;
10191019 const images = this . readImages ( dep . parseJRes ( ) , isProject ) ;
10201020
1021- for ( const image of images ) {
1022- image . meta . package = dep . id ;
1023- if ( image . type === AssetType . Tile ) {
1021+ for ( const toAdd of images ) {
1022+ toAdd . meta . package = dep . id ;
1023+ if ( toAdd . type === AssetType . Tile ) {
10241024 if ( isProject ) {
1025- this . state . tiles . add ( image ) ;
1025+ this . state . tiles . add ( toAdd ) ;
10261026 }
10271027 else {
1028- this . gallery . tiles . add ( image ) ;
1028+ this . gallery . tiles . add ( toAdd ) ;
10291029 }
10301030 }
1031- else if ( image . type === AssetType . Image ) {
1031+ else if ( toAdd . type === AssetType . Image ) {
10321032 if ( isProject ) {
1033- this . state . images . add ( image ) ;
1033+ this . state . images . add ( toAdd ) ;
10341034 }
10351035 else {
1036- this . gallery . images . add ( image ) ;
1036+ this . gallery . images . add ( toAdd ) ;
10371037 }
10381038 }
1039- else if ( image . type === AssetType . Animation ) {
1039+ else if ( toAdd . type === AssetType . Animation ) {
10401040 if ( isProject ) {
1041- this . state . animations . add ( image ) ;
1041+ this . state . animations . add ( toAdd ) ;
10421042 }
10431043 else {
1044- this . gallery . animations . add ( image ) ;
1044+ this . gallery . animations . add ( toAdd ) ;
10451045 }
10461046 }
10471047 else {
10481048 if ( isProject ) {
1049- this . state . songs . add ( image ) ;
1049+ // there was a bug at one point that caused songs to be erroneously serialized
1050+ // with ids in the myImages namespace. if that's the case here, remap the id to
1051+ // the correct namespace before loading it
1052+ const IMAGE_NAMESPACE = pxt . sprite . IMAGES_NAMESPACE + "." ;
1053+ if ( toAdd . id . startsWith ( IMAGE_NAMESPACE ) ) {
1054+ toAdd . id = toAdd . id . replace ( IMAGE_NAMESPACE , pxt . sprite . SONG_NAMESPACE + "." ) ;
1055+ }
1056+ this . state . songs . add ( toAdd ) ;
10501057 }
10511058 else {
1052- this . gallery . songs . add ( image ) ;
1059+ this . gallery . songs . add ( toAdd ) ;
10531060 }
10541061 }
10551062 }
0 commit comments