From d77fc8b26ad7a73e1275a05c8011c9aa8b1a9eb8 Mon Sep 17 00:00:00 2001 From: memelotsqui Date: Mon, 30 Oct 2023 23:23:19 -0600 Subject: [PATCH] validate a trait is selected --- src/components/Selector.jsx | 50 ++++++++++++++++++++----------------- 1 file changed, 27 insertions(+), 23 deletions(-) diff --git a/src/components/Selector.jsx b/src/components/Selector.jsx index dc9f45c4..c19ed812 100644 --- a/src/components/Selector.jsx +++ b/src/components/Selector.jsx @@ -175,30 +175,34 @@ export default function Selector({confirmDialog, uploadVRMURL, templateInfo, ani },[selectedOptions]) const loadCustom = (url) => { - - const option = { - item:{ - id:"custom_" + currentTraitName, - name:"Custom " + currentTraitName, - directory:url - }, - trait:templateInfo.traits.find((t) => t.name === currentTraitName) - } - effectManager.setTransitionEffect('switch_item'); - loadOptions([option], false, false, false).then((loadedData)=>{ - URL.revokeObjectURL(url); - let newAvatar = {}; - loadedData.map((data)=>{ - newAvatar = {...newAvatar, ...itemAssign(data)} + if (currentTraitName){ + const option = { + item:{ + id:"custom_" + currentTraitName, + name:"Custom " + currentTraitName, + directory:url + }, + trait:templateInfo.traits.find((t) => t.name === currentTraitName) + } + effectManager.setTransitionEffect('switch_item'); + loadOptions([option], false, false, false).then((loadedData)=>{ + URL.revokeObjectURL(url); + let newAvatar = {}; + loadedData.map((data)=>{ + newAvatar = {...newAvatar, ...itemAssign(data)} + }) + const finalAvatar = {...avatar, ...newAvatar} + setTimeout(() => { + if (Object.keys(finalAvatar).length > 0) { + cullHiddenMeshes(finalAvatar) + } + }, effectManager.transitionTime); + setAvatar(finalAvatar) }) - const finalAvatar = {...avatar, ...newAvatar} - setTimeout(() => { - if (Object.keys(finalAvatar).length > 0) { - cullHiddenMeshes(finalAvatar) - } - }, effectManager.transitionTime); - setAvatar(finalAvatar) - }) + } + else{ + console.log("Please select a trait first"); + } } const uploadTrait = async() =>{