Skip to content
This repository has been archived by the owner on Jun 1, 2024. It is now read-only.

Add Melody Viewer Component #98

Merged
merged 6 commits into from
Mar 7, 2024
Merged

Conversation

Adamv27
Copy link
Contributor

@Adamv27 Adamv27 commented Mar 6, 2024

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.

@Adamv27 Adamv27 requested a review from hcientist March 6, 2024 17:24
Copy link
Contributor

@hcientist hcientist left a 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

/>
</Col>
</Row>
)}
{/* TODO: if the student has already submitted this, do we show their submission here? if so how would they start over? */}
<FlatEditor
Copy link
Contributor

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?

onLoad,
debugMsg
}) {
const [embed, setEmbed] = useState();
Copy link
Contributor

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?

Comment on lines 30 to 75
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]);
Copy link
Contributor

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.

Copy link
Contributor

@hcientist hcientist left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚀

@hcientist hcientist merged commit 4937748 into JMU-CIME:main Mar 7, 2024
1 check failed
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants