refactor: rename some functions

This commit is contained in:
MAZE 2024-06-14 19:08:00 +04:30
parent 9d633a9637
commit 0533460667

View file

@ -27,8 +27,8 @@ export const Sound = forwardRef<HTMLDivElement, SoundProps>(function Sound(
) { ) {
const isPlaying = useSoundStore(state => state.isPlaying); const isPlaying = useSoundStore(state => state.isPlaying);
const play = useSoundStore(state => state.play); const play = useSoundStore(state => state.play);
const select = useSoundStore(state => state.select); const selectSound = useSoundStore(state => state.select);
const unselect = useSoundStore(state => state.unselect); const unselectSound = useSoundStore(state => state.unselect);
const setVolume = useSoundStore(state => state.setVolume); const setVolume = useSoundStore(state => state.setVolume);
const volume = useSoundStore(state => state.sounds[id].volume); const volume = useSoundStore(state => state.sounds[id].volume);
const isSelected = useSoundStore(state => state.sounds[id].isSelected); 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); else if (hidden && !isSelected) unselectHidden(label);
}, [label, isSelected, hidden, selectHidden, unselectHidden]); }, [label, isSelected, hidden, selectHidden, unselectHidden]);
const _select = useCallback(() => { const select = useCallback(() => {
if (locked) return; if (locked) return;
select(id); selectSound(id);
play(); play();
}, [select, play, id, locked]); }, [selectSound, play, id, locked]);
const _unselect = useCallback(() => { const unselect = useCallback(() => {
if (locked) return; if (locked) return;
unselect(id); unselectSound(id);
setVolume(id, 0.5); setVolume(id, 0.5);
}, [unselect, setVolume, id, locked]); }, [unselectSound, setVolume, id, locked]);
const toggle = useCallback(() => { const toggle = useCallback(() => {
if (locked) return; if (locked) return;
if (isSelected) _unselect(); if (isSelected) unselect();
else _select(); else select();
}, [isSelected, _select, _unselect, locked]); }, [isSelected, select, unselect, locked]);
const handleClick = useCallback(() => { const handleClick = useCallback(() => {
toggle(); toggle();