diff --git a/frontend/src/components/ToggleConfig.tsx b/frontend/src/components/ToggleConfig.tsx
new file mode 100644
index 00000000..61b301cc
--- /dev/null
+++ b/frontend/src/components/ToggleConfig.tsx
@@ -0,0 +1,43 @@
+type ToggleConfigProps = {
+ name: string;
+ value: boolean;
+ updateCallback: (name: string, value: boolean) => void;
+ resetCallback?: (arg0: boolean) => void;
+ onValue?: boolean | string;
+ offValue?: boolean | string;
+};
+
+const ToggleConfig = ({
+ name,
+ value,
+ updateCallback,
+ resetCallback = undefined,
+}: ToggleConfigProps) => {
+ return (
+
+
+ {
+ updateCallback(name, event.target.checked);
+ }}
+ />
+ {!value && (
+
+ )}
+ {value && (
+
+ )}
+
+ {resetCallback !== undefined &&
}
+
+ );
+};
+
+export default ToggleConfig;
diff --git a/frontend/src/pages/ChannelAbout.tsx b/frontend/src/pages/ChannelAbout.tsx
index 922a2e6c..edd9c61a 100644
--- a/frontend/src/pages/ChannelAbout.tsx
+++ b/frontend/src/pages/ChannelAbout.tsx
@@ -14,6 +14,7 @@ import Button from '../components/Button';
import updateChannelOverwrites from '../api/actions/updateChannelOverwrite';
import useIsAdmin from '../functions/useIsAdmin';
import InputConfig from '../components/InputConfig';
+import ToggleConfig from '../components/ToggleConfig';
export type ChannelBaseOutletContextType = {
currentPage: number;
@@ -269,30 +270,11 @@ const ChannelAbout = () => {
-
-
-
- {
- handleUpdateConfig('index_playlists', event.target.checked || null);
- }}
- />
- {!indexPlaylists && (
-
- )}
- {indexPlaylists && (
-
- )}
-
-
-
+
@@ -305,29 +287,12 @@ const ChannelAbout = () => {
{enableSponsorblock !== null ? (
-
-
- {
- handleUpdateConfig('integrate_sponsorblock', event.target.checked);
- }}
- />
- {!enableSponsorblock && (
-
- )}
- {enableSponsorblock && (
-
- )}
-
-
-
+
) : (
)}
diff --git a/frontend/src/pages/SettingsApplication.tsx b/frontend/src/pages/SettingsApplication.tsx
index 01c766d7..c3166b52 100644
--- a/frontend/src/pages/SettingsApplication.tsx
+++ b/frontend/src/pages/SettingsApplication.tsx
@@ -12,6 +12,7 @@ import loadAppsettingsConfig, { AppSettingsConfigType } from '../api/loader/load
import updateAppsettingsConfig from '../api/actions/updateAppsettingsConfig';
import loadApiToken from '../api/loader/loadApiToken';
import InputConfig from '../components/InputConfig';
+import ToggleConfig from '../components/ToggleConfig';
type SnapshotType = {
id: string;
@@ -214,31 +215,11 @@ const SettingsApplication = () => {
Autostart download subscriptions
-
-
- {
- handleUpdateConfig(
- 'subscriptions.auto_start',
- event.target.checked || false,
- );
- }}
- />
- {!isAutostart && (
-
- )}
- {isAutostart && (
-
- )}
-
-
+
@@ -341,58 +322,21 @@ const SettingsApplication = () => {
-
-
- {
- handleUpdateConfig('downloads.add_metadata', event.target.checked || false);
- }}
- />
- {!embedMetadata && (
-
- )}
- {embedMetadata && (
-
- )}
-
-
+
-
-
- {
- handleUpdateConfig(
- 'downloads.add_thumbnail',
- event.target.checked || false,
- );
- }}
- />
- {!embedThumbnail && (
-
- )}
- {embedThumbnail && (
-
- )}
-
-
+
@@ -446,28 +390,11 @@ const SettingsApplication = () => {
-
-
- {
- handleUpdateConfig('downloads.subtitle_index', event.target.checked);
- }}
- />
- {!indexSubtitles && (
-
- )}
- {indexSubtitles && (
-
- )}
-
-
+
>
)}
@@ -540,58 +467,21 @@ const SettingsApplication = () => {
Enable returnyoutubedislike
-
-
- {
- handleUpdateConfig('downloads.integrate_ryd', event.target.checked);
- }}
- />
- {!downloadDislikes && (
-
- )}
- {downloadDislikes && (
-
- )}
-
-
+
-
-
- {
- handleUpdateConfig(
- 'downloads.integrate_sponsorblock',
- event.target.checked,
- );
- }}
- />
- {!enableSponsorBlock && (
-
- )}
- {enableSponsorBlock && (
-
- )}
-
-
+
@@ -600,30 +490,11 @@ const SettingsApplication = () => {
-
-
-
- {
- handleUpdateConfig('application.enable_snapshot', event.target.checked);
- }}
- />
- {!enableSnapshots && (
-
- )}
- {enableSnapshots && (
-
- )}
-
-
-
+