Browse Source

Add config for system notifications

master
jeffvli 3 years ago
committed by Jeff
parent
commit
631c5efae7
  1. 3
      src/__tests__/App.test.tsx
  2. 17
      src/components/settings/ConfigPanels/PlayerConfig.tsx
  3. 4
      src/components/shared/setDefaultSettings.ts
  4. 14
      src/redux/configSlice.ts
  5. 1
      src/shared/mockSettings.ts

3
src/__tests__/App.test.tsx

@ -133,6 +133,9 @@ const configState: ConfigPage = {
filters: [], filters: [],
}, },
sort: {}, sort: {},
player: {
systemNotifications: false,
},
serverType: Server.Subsonic, serverType: Server.Subsonic,
lookAndFeel: { lookAndFeel: {
font: 'Poppins', font: 'Poppins',

17
src/components/settings/ConfigPanels/PlayerConfig.tsx

@ -20,7 +20,7 @@ import { useAppDispatch, useAppSelector } from '../../../redux/hooks';
import i18n from '../../../i18n/i18n'; import i18n from '../../../i18n/i18n';
import { setPlaybackSetting } from '../../../redux/playQueueSlice'; import { setPlaybackSetting } from '../../../redux/playQueueSlice';
import ListViewTable from '../../viewtypes/ListViewTable'; import ListViewTable from '../../viewtypes/ListViewTable';
import { appendPlaybackFilter, setAudioDeviceId } from '../../../redux/configSlice'; import { appendPlaybackFilter, setAudioDeviceId, setPlayer } from '../../../redux/configSlice';
import { notifyToast } from '../../shared/toast'; import { notifyToast } from '../../shared/toast';
import ConfigOption from '../ConfigOption'; import ConfigOption from '../ConfigOption';
import { Server } from '../../../types'; import { Server } from '../../../types';
@ -279,6 +279,21 @@ const PlayerConfig = ({ bordered }: any) => {
/> />
)} )}
<ConfigOption
name={t('System Notifications')}
description={<>{t('Show a system notification whenever the song changes.')}</>}
option={
<StyledToggle
defaultChecked={config.player.systemNotifications}
checked={config.player.systemNotifications}
onChange={(e: boolean) => {
settings.setSync('systemNotifications', e);
dispatch(setPlayer({ systemNotifications: e }));
}}
/>
}
/>
<ConfigOption <ConfigOption
name={t('Scrobble')} name={t('Scrobble')}
description={t( description={t(

4
src/components/shared/setDefaultSettings.ts

@ -111,6 +111,10 @@ const setDefaultSettings = (force: boolean) => {
settings.setSync('scrobble', false); settings.setSync('scrobble', false);
} }
if (force || !settings.hasSync('systemNotifications')) {
settings.setSync('systemNotifications', false);
}
if (force || !settings.hasSync('musicFolder.id')) { if (force || !settings.hasSync('musicFolder.id')) {
settings.setSync('musicFolder.id', null); settings.setSync('musicFolder.id', null);
} }

14
src/redux/configSlice.ts

@ -28,6 +28,9 @@ export interface ConfigPage {
genreListPage?: SortColumn; genreListPage?: SortColumn;
playlistListPage?: SortColumn; playlistListPage?: SortColumn;
}; };
player: {
systemNotifications: boolean;
};
lookAndFeel: { lookAndFeel: {
font: string; font: string;
listView: { listView: {
@ -106,6 +109,9 @@ const initialState: ConfigPage = {
filters: parsedSettings.playbackFilters, filters: parsedSettings.playbackFilters,
audioDeviceId: parsedSettings.audioDeviceId || undefined, audioDeviceId: parsedSettings.audioDeviceId || undefined,
}, },
player: {
systemNotifications: parsedSettings.systemNotifications,
},
sort: { sort: {
albumListPage: undefined, albumListPage: undefined,
albumPage: undefined, albumPage: undefined,
@ -223,6 +229,13 @@ const configSlice = createSlice({
}; };
}, },
setPlayer: (state, action: PayloadAction<any>) => {
state.player = {
...state.player,
...action.payload,
};
},
setWindow: (state, action: PayloadAction<any>) => { setWindow: (state, action: PayloadAction<any>) => {
state.window = { ...state.window, ...action.payload }; state.window = { ...state.window, ...action.payload };
}, },
@ -354,5 +367,6 @@ export const {
setOBS, setOBS,
setSidebar, setSidebar,
setWindow, setWindow,
setPlayer,
} = configSlice.actions; } = configSlice.actions;
export default configSlice.reducer; export default configSlice.reducer;

1
src/shared/mockSettings.ts

@ -22,6 +22,7 @@ export const mockSettings = {
pollingInterval: 20, pollingInterval: 20,
fadeDuration: 9, fadeDuration: 9,
fadeType: 'equalPower', fadeType: 'equalPower',
systemNotifications: false,
scrobble: false, scrobble: false,
transcode: false, transcode: false,
sidebar: { sidebar: {

Loading…
Cancel
Save