From bc61eec235d745f3635f8b43c3ce183afd738893 Mon Sep 17 00:00:00 2001 From: Kevin Ngo Date: Sun, 9 Dec 2018 03:59:12 -0800 Subject: [PATCH] update num beats on difficulty select (fixes #224) --- src/state/index.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/state/index.js b/src/state/index.js index 8e3c383..982b696 100644 --- a/src/state/index.js +++ b/src/state/index.js @@ -334,7 +334,7 @@ AFRAME.registerState({ state.menuSelectedChallenge.difficulty = state.menuDifficulties[0]; state.menuSelectedChallenge.image = utils.getS3FileUrl(id, 'image.jpg'); - state.menuSelectedChallenge.songInfoText = `By ${truncate(challenge.author, 12)} ${challenge.genre && challenge.genre !== 'Uncategorized' ? '/ ' + challenge.genre : ''}\n${challenge.downloads} Downloads\nUpvotes: ${challenge.upvotes} / Downvotes: ${challenge.downvotes}\n${formatSongLength(challenge.songDuration)} / ${challenge.numBeats[state.menuSelectedChallenge.difficulty]} beats`; + updateMenuSongInfo(state, challenge); computeMenuSelectedChallengeIndex(state); state.isSearching = false; @@ -350,6 +350,7 @@ AFRAME.registerState({ menudifficultyselect: (state, difficulty) => { state.menuSelectedChallenge.difficulty = difficulty; clearLeaderboard(state); + updateMenuSongInfo(state, state.menuSelectedChallenge); }, minehit: state => { @@ -623,3 +624,7 @@ function clearLeaderboard (state) { state.leaderboardScores = ''; state.leaderboardFetched = false; } + +function updateMenuSongInfo (state, challenge) { + state.menuSelectedChallenge.songInfoText = `By ${truncate(challenge.author, 12)} ${challenge.genre && challenge.genre !== 'Uncategorized' ? '/ ' + challenge.genre : ''}\n${challenge.downloads} Downloads\nUpvotes: ${challenge.upvotes} / Downvotes: ${challenge.downvotes}\n${formatSongLength(challenge.songDuration)} / ${challenge.numBeats[state.menuSelectedChallenge.difficulty]} beats`; +}