-
Notifications
You must be signed in to change notification settings - Fork 28
Conversation
Use new melody viewer component in exploratory create
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Take a look at the couple comments and tell me what you think
components/student/create/aural.js
Outdated
/> | ||
</Col> | ||
</Row> | ||
)} | ||
{/* TODO: if the student has already submitted this, do we show their submission here? if so how would they start over? */} | ||
<FlatEditor |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably you should move this FlatEditor inside the jsonh condition along with the 3 chordscalebucketscores?
components/flatMelodyViewer.js
Outdated
onLoad, | ||
debugMsg | ||
}) { | ||
const [embed, setEmbed] = useState(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
shouldn't this be a case of useRef?
components/flatMelodyViewer.js
Outdated
useEffect(() => { | ||
const allParams = { | ||
height: `${height}`, | ||
width: width, | ||
embedParams, | ||
}; | ||
setEmbed(new Embed(editorRef.current, allParams)); | ||
}, [height]); | ||
|
||
useEffect(() => { | ||
if (!embed) return; | ||
const loadParams = { | ||
score: score.scoreId, | ||
}; | ||
if (score.sharingKey) { | ||
loadParams.sharingKey = score.sharingKey; | ||
} | ||
embed | ||
.ready() | ||
.then( | ||
() => | ||
embed | ||
.loadFlatScore(loadParams) | ||
.then(() => { | ||
embed | ||
.getJSON() | ||
.then( | ||
(jsonData) => onLoad && onLoad(JSON.stringify(jsonData)) | ||
); | ||
}) | ||
.catch((e) => { | ||
if (e && e.message) { | ||
e.message = `flat error: ${e?.message}, not loaded from scoreId, score: ${JSON.stringify(score)}`; | ||
if (debugMsg){ | ||
e.message = `${e?.message}, debugMsg: ${debugMsg}`; | ||
} | ||
} else if(debugMsg) { | ||
console.error('debugMsg', debugMsg); | ||
if (score){console.error('score', score);} | ||
} | ||
console.error('score not loaded from scoreId'); | ||
console.error('score', score); | ||
throw e; | ||
}) | ||
); | ||
}, [embed]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I know you didn't come up with this, but are just trying to survive my past code crimes, but it seems like there's really never a case for either of these 2 embeds to be run independently of the other.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🚀
Add component specifically for loading the melody with no extra features. Replace the usage of FlatEditor with this new component in aural, exploratory, and theoretical. Some of the components on those pages attempted to load at the same time as the old FlatEditor even though they depended on the FlatEditors output. I added a conditional to only render them if the melody has been loaded.