Browse Source

add repeat/shuffle to settings by playerbar

- defaultShuffle -> shuffle
- defaultRepeat -> repeat
- remove set in config
master
jeffvli 3 years ago
parent
commit
c944dfff40
  1. 9
      src/components/player/PlayerBar.tsx
  2. 43
      src/components/settings/Config.tsx
  3. 8
      src/components/shared/setDefaultSettings.ts
  4. 4
      src/shared/utils.ts

9
src/components/player/PlayerBar.tsx

@ -242,11 +242,20 @@ const PlayerBar = () => {
};
const handleRepeat = () => {
const currentRepeat = settings.getSync('repeat');
const newRepeat =
currentRepeat === 'none'
? 'all'
: currentRepeat === 'all'
? 'one'
: 'none';
dispatch(toggleRepeat());
settings.setSync('repeat', newRepeat);
};
const handleShuffle = () => {
dispatch(toggleShuffle());
settings.setSync('shuffle', !settings.getSync('shuffle'));
};
const handleDisplayQueue = () => {

43
src/components/settings/Config.tsx

@ -188,49 +188,6 @@ const Config = () => {
}}
style={{ width: '150px' }}
/>
<br />
<RadioGroup
name="radioList"
inline
appearance="picker"
defaultValue={String(settings.getSync('defaultRepeat'))}
onChange={(e) => settings.setSync('defaultRepeat', e)}
>
<span
style={{
padding: '8px 2px 8px 10px',
display: 'inline-block',
verticalAlign: 'middle',
}}
>
Repeat (default):{' '}
</span>
<Radio value="all">All</Radio>
<Radio value="one">One</Radio>
<Radio value="none">None</Radio>
</RadioGroup>
<RadioGroup
name="radioList"
inline
appearance="picker"
defaultValue={String(settings.getSync('defaultShuffle'))}
style={{ marginTop: '20px' }}
onChange={(e) => settings.setSync('defaultShuffle', e === 'true')}
>
<span
style={{
padding: '8px 2px 8px 10px',
display: 'inline-block',
verticalAlign: 'middle',
}}
>
Shuffle (default):{' '}
</span>
<Radio value="true">Enabled</Radio>
<Radio value="false">Disabled</Radio>
</RadioGroup>
<br />
</div>
</ConfigPanel>
<ConfigPanel header="Look & Feel" bordered>

8
src/components/shared/setDefaultSettings.ts

@ -15,12 +15,12 @@ const setDefaultSettings = (force: boolean) => {
fs.mkdirSync(getSongCachePath(), { recursive: true });
fs.mkdirSync(getImageCachePath(), { recursive: true });
if (force || !settings.hasSync('defaultRepeat')) {
settings.setSync('defaultRepeat', 'all');
if (force || !settings.hasSync('repeat')) {
settings.setSync('repeat', 'all');
}
if (force || !settings.hasSync('defaultShuffle')) {
settings.setSync('defaultShuffle', false);
if (force || !settings.hasSync('shuffle')) {
settings.setSync('shuffle', false);
}
if (force || !settings.hasSync('scrollWithCurrentSong')) {

4
src/shared/utils.ts

@ -17,8 +17,8 @@ settingsPath = fs.existsSync(settingsPath)
export const getSettings = () => {
const parsedSettings = JSON.parse(String(fs.readFileSync(settingsPath)));
return {
repeat: parsedSettings.defaultRepeat,
shuffle: parsedSettings.defaultShuffle,
repeat: parsedSettings.repeat,
shuffle: parsedSettings.shuffle,
volume: parsedSettings.volume,
};
};

Loading…
Cancel
Save