mirror of
https://github.com/remvze/moodist.git
synced 2025-12-17 00:44:14 +00:00
refactor: rename some functions
This commit is contained in:
parent
9d633a9637
commit
0533460667
1 changed files with 11 additions and 11 deletions
|
|
@ -27,8 +27,8 @@ export const Sound = forwardRef<HTMLDivElement, SoundProps>(function Sound(
|
|||
) {
|
||||
const isPlaying = useSoundStore(state => state.isPlaying);
|
||||
const play = useSoundStore(state => state.play);
|
||||
const select = useSoundStore(state => state.select);
|
||||
const unselect = useSoundStore(state => state.unselect);
|
||||
const selectSound = useSoundStore(state => state.select);
|
||||
const unselectSound = useSoundStore(state => state.unselect);
|
||||
const setVolume = useSoundStore(state => state.setVolume);
|
||||
const volume = useSoundStore(state => state.sounds[id].volume);
|
||||
const isSelected = useSoundStore(state => state.sounds[id].isSelected);
|
||||
|
|
@ -53,23 +53,23 @@ export const Sound = forwardRef<HTMLDivElement, SoundProps>(function Sound(
|
|||
else if (hidden && !isSelected) unselectHidden(label);
|
||||
}, [label, isSelected, hidden, selectHidden, unselectHidden]);
|
||||
|
||||
const _select = useCallback(() => {
|
||||
const select = useCallback(() => {
|
||||
if (locked) return;
|
||||
select(id);
|
||||
selectSound(id);
|
||||
play();
|
||||
}, [select, play, id, locked]);
|
||||
}, [selectSound, play, id, locked]);
|
||||
|
||||
const _unselect = useCallback(() => {
|
||||
const unselect = useCallback(() => {
|
||||
if (locked) return;
|
||||
unselect(id);
|
||||
unselectSound(id);
|
||||
setVolume(id, 0.5);
|
||||
}, [unselect, setVolume, id, locked]);
|
||||
}, [unselectSound, setVolume, id, locked]);
|
||||
|
||||
const toggle = useCallback(() => {
|
||||
if (locked) return;
|
||||
if (isSelected) _unselect();
|
||||
else _select();
|
||||
}, [isSelected, _select, _unselect, locked]);
|
||||
if (isSelected) unselect();
|
||||
else select();
|
||||
}, [isSelected, select, unselect, locked]);
|
||||
|
||||
const handleClick = useCallback(() => {
|
||||
toggle();
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue