Be sure to not register again asset with same url, create a-assets if missing #824
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.



Steps to reproduce:
What it should do is showing the existing asset id "crateImg" and not "crate" to not register the same asset a second time.
I now show the message "Texture already loaded" and the "LOAD THIS TEXTURE" button stays disabled in this case.
I also now handle the case "Name already taken by another asset or entity".
The code
that is executed after selecting a texture that closes the modal probably took care of reusing the same asset in the past but it was a dead branch in the current code,
image.typeis always "asset" here becauseprops.onClose(value)is called fromselectTexturethat is used only on registered assets.I removed that code and the
insertOrGetImageAssetfunction and reintroduced a check in the load texture step to check for existing asset with the same url.I removed the duplicate
insertNewAsset/getFilenamefunctions and movedgetFilename,isValidId,getValidId,getUrlFromIdand added newgetIdFromUrltoassetsUtils.jsto be reused with other type of assets and not only img in the future (like selecting an audio for the sound component).The
a-assetselement is now created if it doesn't exist, it gave an error previously.The input field and preview is now cleared if you click on the BACK button.