Browse Source

Rename 'Add random' -> 'Auto playlist'

master
jeffvli 3 years ago
committed by Jeff
parent
commit
d34128183e
  1. 44
      src/components/player/NowPlayingView.tsx
  2. 2
      src/components/shared/ToolbarButtons.tsx

44
src/components/player/NowPlayingView.tsx

@ -48,16 +48,16 @@ import { notifyToast } from '../shared/toast';
const NowPlayingView = () => { const NowPlayingView = () => {
const tableRef = useRef<any>(); const tableRef = useRef<any>();
const addRandomTriggerRef = useRef<any>(); const autoPlaylistTriggerRef = useRef<any>();
const dispatch = useAppDispatch(); const dispatch = useAppDispatch();
const playQueue = useAppSelector((state) => state.playQueue); const playQueue = useAppSelector((state) => state.playQueue);
const multiSelect = useAppSelector((state) => state.multiSelect); const multiSelect = useAppSelector((state) => state.multiSelect);
const config = useAppSelector((state) => state.config); const config = useAppSelector((state) => state.config);
const [randomPlaylistTrackCount, setRandomPlaylistTrackCount] = useState( const [autoPlaylistTrackCount, setRandomPlaylistTrackCount] = useState(
Number(settings.getSync('randomPlaylistTrackCount')) Number(settings.getSync('randomPlaylistTrackCount'))
); );
const [randomPlaylistFromYear, setRandomPlaylistFromYear] = useState(0); const [autoPlaylistFromYear, setRandomPlaylistFromYear] = useState(0);
const [randomPlaylistToYear, setRandomPlaylistToYear] = useState(0); const [autoPlaylistToYear, setRandomPlaylistToYear] = useState(0);
const [randomPlaylistGenre, setRandomPlaylistGenre] = useState(''); const [randomPlaylistGenre, setRandomPlaylistGenre] = useState('');
const [isLoadingRandom, setIsLoadingRandom] = useState(false); const [isLoadingRandom, setIsLoadingRandom] = useState(false);
@ -166,14 +166,14 @@ const NowPlayingView = () => {
const handlePlayRandom = async (action: 'play' | 'addNext' | 'addLater') => { const handlePlayRandom = async (action: 'play' | 'addNext' | 'addLater') => {
setIsLoadingRandom(true); setIsLoadingRandom(true);
const res = await getRandomSongs({ const res = await getRandomSongs({
size: randomPlaylistTrackCount, size: autoPlaylistTrackCount,
fromYear: randomPlaylistFromYear !== 0 ? randomPlaylistFromYear : undefined, fromYear: autoPlaylistFromYear !== 0 ? autoPlaylistFromYear : undefined,
toYear: randomPlaylistToYear !== 0 ? randomPlaylistToYear : undefined, toYear: autoPlaylistToYear !== 0 ? autoPlaylistToYear : undefined,
genre: randomPlaylistGenre, genre: randomPlaylistGenre,
}); });
if (isFailedResponse(res)) { if (isFailedResponse(res)) {
addRandomTriggerRef.current.close(); autoPlaylistTriggerRef.current.close();
return notifyToast('error', errorMessages(res)[0]); return notifyToast('error', errorMessages(res)[0]);
} }
@ -214,7 +214,7 @@ const NowPlayingView = () => {
} }
setIsLoadingRandom(false); setIsLoadingRandom(false);
return addRandomTriggerRef.current.close(); return autoPlaylistTriggerRef.current.close();
}; };
const handleRowFavorite = async (rowData: any) => { const handleRowFavorite = async (rowData: any) => {
@ -262,7 +262,7 @@ const NowPlayingView = () => {
}} }}
/> />
<Whisper <Whisper
ref={addRandomTriggerRef} ref={autoPlaylistTriggerRef}
placement="autoVertical" placement="autoVertical"
trigger="none" trigger="none"
speaker={ speaker={
@ -273,8 +273,8 @@ const NowPlayingView = () => {
min={1} min={1}
max={500} max={500}
step={10} step={10}
defaultValue={randomPlaylistTrackCount} defaultValue={autoPlaylistTrackCount}
value={randomPlaylistTrackCount} value={autoPlaylistTrackCount}
onChange={(e: number) => { onChange={(e: number) => {
settings.setSync('randomPlaylistTrackCount', Number(e)); settings.setSync('randomPlaylistTrackCount', Number(e));
setRandomPlaylistTrackCount(Number(e)); setRandomPlaylistTrackCount(Number(e));
@ -294,8 +294,8 @@ const NowPlayingView = () => {
min={0} min={0}
max={3000} max={3000}
step={1} step={1}
defaultValue={randomPlaylistFromYear} defaultValue={autoPlaylistFromYear}
value={randomPlaylistFromYear} value={autoPlaylistFromYear}
onChange={(e: number) => { onChange={(e: number) => {
setRandomPlaylistFromYear(Number(e)); setRandomPlaylistFromYear(Number(e));
}} }}
@ -312,8 +312,8 @@ const NowPlayingView = () => {
min={0} min={0}
max={3000} max={3000}
step={1} step={1}
defaultValue={randomPlaylistToYear} defaultValue={autoPlaylistToYear}
value={randomPlaylistToYear} value={autoPlaylistToYear}
onChange={(e: number) => setRandomPlaylistToYear(Number(e))} onChange={(e: number) => setRandomPlaylistToYear(Number(e))}
/> />
</StyledInputGroup> </StyledInputGroup>
@ -335,14 +335,14 @@ const NowPlayingView = () => {
<StyledButton <StyledButton
onClick={() => handlePlayRandom('addNext')} onClick={() => handlePlayRandom('addNext')}
loading={isLoadingRandom} loading={isLoadingRandom}
disabled={!(typeof randomPlaylistTrackCount === 'number')} disabled={!(typeof autoPlaylistTrackCount === 'number')}
> >
<Icon icon="plus-circle" style={{ marginRight: '10px' }} /> Add (next) <Icon icon="plus-circle" style={{ marginRight: '10px' }} /> Add (next)
</StyledButton> </StyledButton>
<StyledButton <StyledButton
onClick={() => handlePlayRandom('addLater')} onClick={() => handlePlayRandom('addLater')}
loading={isLoadingRandom} loading={isLoadingRandom}
disabled={!(typeof randomPlaylistTrackCount === 'number')} disabled={!(typeof autoPlaylistTrackCount === 'number')}
> >
<Icon icon="plus" style={{ marginRight: '10px' }} /> Add (later) <Icon icon="plus" style={{ marginRight: '10px' }} /> Add (later)
</StyledButton> </StyledButton>
@ -353,7 +353,7 @@ const NowPlayingView = () => {
appearance="primary" appearance="primary"
onClick={() => handlePlayRandom('play')} onClick={() => handlePlayRandom('play')}
loading={isLoadingRandom} loading={isLoadingRandom}
disabled={!(typeof randomPlaylistTrackCount === 'number')} disabled={!(typeof autoPlaylistTrackCount === 'number')}
> >
<Icon icon="play" style={{ marginRight: '10px' }} /> <Icon icon="play" style={{ marginRight: '10px' }} />
Play Play
@ -365,9 +365,9 @@ const NowPlayingView = () => {
<AutoPlaylistButton <AutoPlaylistButton
size="sm" size="sm"
onClick={() => onClick={() =>
addRandomTriggerRef.current.state.isOverlayShown autoPlaylistTriggerRef.current.state.isOverlayShown
? addRandomTriggerRef.current.close() ? autoPlaylistTriggerRef.current.close()
: addRandomTriggerRef.current.open() : autoPlaylistTriggerRef.current.open()
} }
/> />
</Whisper> </Whisper>

2
src/components/shared/ToolbarButtons.tsx

@ -133,7 +133,7 @@ export const AutoPlaylistButton = ({ ...rest }) => {
return ( return (
<StyledButton tabIndex={0} {...rest}> <StyledButton tabIndex={0} {...rest}>
<Icon icon="plus-square" style={{ marginRight: '10px' }} /> <Icon icon="plus-square" style={{ marginRight: '10px' }} />
Add random Auto playlist
</StyledButton> </StyledButton>
); );
}; };

Loading…
Cancel
Save