Repository navigation
fix(client): get sound value from redux to play sound - #48107
nayabatir1 wants to merge 2 commits into
Conversation
|
👀 Review this PR in a CodeSee Review Map |
|
Please take a moment to give a name to the PR that follows the guidelines: https://contribute.freecodecamp.org/#/how-to-open-a-pull-request?id=prepare-a-good-pr-title |
raisedadead
left a comment
There was a problem hiding this comment.
Why are you re-arranging the unrelated imports?
Other than that, I like the idea of not needing to use the localStorage, but others are better qualified to confirm.
| @@ -1,4 +1,5 @@ | |||
| import store from 'store'; | |||
| import * as Tone from 'tone'; | |||
There was a problem hiding this comment.
| import * as Tone from 'tone'; |
What's the rationale for this change? We deliberately do not statically import tone because it's a large library that not all users need to view the site.
There was a problem hiding this comment.
I used this way of import b'cuz it is mentioned in npm. I've also checked bundle size

I did some research and found a better way to import is import { loaded, Player } from 'tone';.
Taking advantage of tree shaking.
If it seem fit I can change it or revert back to previous way importing.
I've updated pr title |
|
I did some research and found that audio can be played without any dependency. I think we should definitely use this method const audio = new Audio(toneUrls[state]);
const storedVolume = (store.get('soundVolume') as number) ?? 50;
const calculateDecibel = storedVolume / 100;
audio.volume = calculateDecibel;
await audio.play(); |
|
You do not need to work on the other PR (the other solution). Just wait on some conclusive comments from others. This is likely the version we want. You are welcome to hang on to the other if you prefer - but if there is anything the maintainers like, that is less noise. |
Sorry if it bothers you. |
|
#48106 (review) applies here, too. I hadn't realised there were two PRs solving the same issue.
The reason is that small, focused PRs are easier to understand. This makes it easier for reviewers to see if there are any issues that need to be addressed before merging. Also, if we later find that there are problems, it's easier to debug them. |
That's not the problem. The issue is you have two PRs, making it hard for multiple people to review your work. You may be working on a couple of issues; the maintainers deal with a dozen PRs. It is easy for us to lose context. We get that you have two different approaches, and the simplest thing to do in such cases would be to keep the discussion on the most favored approach (this PR) and not work on the other one until you are asked to. It would have been even better to get a confirmation on the main issue before you started – but we are past that. Let's focus on working on the review of this PR. |
777f8e1 to
fb48226
Compare
The purpose of using Tone specifically was the ability to easily generate dynamic audio in the editor - while it would be possible to do so with the raw Audio context, IMHO it's not worth the overhead. |
|
@ojeytonwilliams can I create checkout of this branch for removing tone package. Checkout of main branch will result in merge conflict as both branch modify same function |
|
Sorry, @nayabatir1, I hadn't realised why we were using Tone specifically. @naomi-lgbt understands this issue better than I do, so I will defer to her. For this PR, please could you keep the changes to those needed to fix the original issue, #46372? There's no need to re-arrange the imports or change to statically importing to address that. |
naomi-lgbt
left a comment
There was a problem hiding this comment.
Because the logic to check store has been removed from playTone, there are a few different areas where we'll need to check the user's settings:
- client/src/components/Donation/donation-modal.tsx
- client/src/components/Flash/redux/index.ts
- client/src/components/settings/sound.tsx
- client/src/templates/Challenges/redux/execute-challenge-saga.js
|
@naomi-lgbt I looked into all the mentioned files. |
|
We can certainly consider that approach, though we'd need to not remove Tone in the process. |
@naomi-lgbt I've updated pr. |

Checklist:
Update index.md)mainbranch of freeCodeCamp.Closes #46372
Closes #48106
This 2nd method of solving issue.
Here I've removed
localstoragedependency fromplayTone. Sound value is grabbed directly from redux and audio is played accordingly.