From 325312dca6ef77b686dfccc87cc0a6e175683f31 Mon Sep 17 00:00:00 2001 From: jeffvli Date: Sat, 4 Sep 2021 05:10:36 -0700 Subject: [PATCH] add configurable seek intervals --- src/components/player/PlayerBar.tsx | 12 ++++----- src/components/settings/Config.tsx | 30 +++++++++++++++++++++ src/components/shared/setDefaultSettings.ts | 10 ++++++- 3 files changed, 45 insertions(+), 7 deletions(-) diff --git a/src/components/player/PlayerBar.tsx b/src/components/player/PlayerBar.tsx index b1d9c91..3caa99d 100644 --- a/src/components/player/PlayerBar.tsx +++ b/src/components/player/PlayerBar.tsx @@ -50,12 +50,6 @@ const PlayerBar = () => { const [localVolume, setLocalVolume] = useState( Number(settings.getSync('volume')) ); - const [seekForwardInterval] = useState( - Number(settings.getSync('seekForwardInterval')) || 5 - ); - const [seekBackwardInterval] = useState( - Number(settings.getSync('seekBackwardInterval')) || 5 - ); const playersRef = useRef(); const history = useHistory(); @@ -180,6 +174,9 @@ const PlayerBar = () => { const handleClickForward = () => { if (playQueue[currentEntryList].length > 0) { + const seekForwardInterval = Number( + settings.getSync('seekForwardInterval') + ); setIsDragging(true); if (playQueue.isFading) { @@ -219,6 +216,9 @@ const PlayerBar = () => { }; const handleClickBackward = () => { + const seekBackwardInterval = Number( + settings.getSync('seekBackwardInterval') + ); if (playQueue[currentEntryList].length > 0) { setIsDragging(true); diff --git a/src/components/settings/Config.tsx b/src/components/settings/Config.tsx index 10d5944..e595e7e 100644 --- a/src/components/settings/Config.tsx +++ b/src/components/settings/Config.tsx @@ -346,6 +346,36 @@ const Config = () => { /> )} + +

+ Configure the number of seconds to skip forwards/backwards by when + clicking the seek forward/backward buttons. +

+
+ Seek forward (s) + { + settings.setSync('seekForwardInterval', Number(e)); + }} + style={{ width: '150px' }} + /> +
+ Seek backward (s) + { + settings.setSync('seekBackwardInterval', Number(e)); + }} + style={{ width: '150px' }} + /> +
{errorMessage !== '' && ( <> diff --git a/src/components/shared/setDefaultSettings.ts b/src/components/shared/setDefaultSettings.ts index 39db8c6..3684b70 100644 --- a/src/components/shared/setDefaultSettings.ts +++ b/src/components/shared/setDefaultSettings.ts @@ -16,6 +16,14 @@ const setDefaultSettings = (force: boolean) => { settings.setSync('volume', 0.5); } + if (force || !settings.hasSync('seekForwardInterval')) { + settings.setSync('seekForwardInterval', 5); + } + + if (force || !settings.hasSync('seekBackwardInterval')) { + settings.setSync('seekBackwardInterval', 5); + } + if (force || !settings.hasSync('volumeFade')) { settings.setSync('volumeFade', true); } @@ -48,7 +56,7 @@ const setDefaultSettings = (force: boolean) => { } if (force || !settings.hasSync('fadeDuration')) { - settings.setSync('fadeDuration', '9.0'); + settings.setSync('fadeDuration', 9); } if (force || !settings.hasSync('fadeType')) {