diff --git a/src/components/Layout/Settings/PreferencesWrapper/PreferencesWrapper.jsx b/src/components/Layout/Settings/PreferencesWrapper/PreferencesWrapper.jsx
index 063065e8..99ede687 100644
--- a/src/components/Layout/Settings/PreferencesWrapper/PreferencesWrapper.jsx
+++ b/src/components/Layout/Settings/PreferencesWrapper/PreferencesWrapper.jsx
@@ -7,7 +7,8 @@ import values from 'utils/data/slider_values.json';
import EventBus from 'utils/eventbus';
const PreferencesWrapper = ({ children, ...props }) => {
- const [shown, setShown] = useState(localStorage.getItem(props.setting) === 'true');
+ const [shown, setShown] = useState(localStorage.getItem(props.setting) === 'true' || props.default || false);
+ console.log(props.default)
EventBus.on('toggle', (setting) => {
if (setting === props.setting) {
diff --git a/src/features/quote/options/Custom.jsx b/src/features/quote/options/Custom.jsx
new file mode 100644
index 00000000..88cc9897
--- /dev/null
+++ b/src/features/quote/options/Custom.jsx
@@ -0,0 +1,117 @@
+import variables from 'config/variables';
+import { useState } from 'react';
+import { MdCancel, MdAdd, MdOutlineFormatQuote } from 'react-icons/md';
+import TextareaAutosize from '@mui/material/TextareaAutosize';
+
+import { Row, Content, Action } from 'components/Layout/Settings';
+import { Button } from 'components/Elements';
+
+function CustomSettings() {
+ const [customQuote, setCustomQuote] = useState(getCustom());
+
+ function handleCustomQuote(e, index, type) {
+ const result = e.target.value;
+ const newCustomQuote = [...customQuote];
+ newCustomQuote[index][type] = result;
+ setCustomQuote(newCustomQuote);
+ localStorage.setItem('customQuote', JSON.stringify(newCustomQuote));
+ document.querySelector('.reminder-info').style.display = 'flex';
+ localStorage.setItem('showReminder', true);
+ }
+
+ function modifyCustomQuote(type, index) {
+ let newCustomQuote = [...customQuote];
+ if (type === 'add') {
+ newCustomQuote.push({ quote: '', author: '' });
+ } else {
+ newCustomQuote.splice(index, 1);
+ }
+ setCustomQuote(newCustomQuote);
+ localStorage.setItem('customQuote', JSON.stringify(newCustomQuote));
+ }
+
+ function getCustom() {
+ let data = JSON.parse(localStorage.getItem('customQuote'));
+ if (data === null) {
+ data = [];
+ }
+ return data;
+ }
+
+ const QUOTE_SECTION = 'modals.main.settings.sections.quote';
+
+ return (
+ <>
+
+
+
+
+
+
+ {customQuote.length !== 0 ? (
+
+ {customQuote.map((_url, index) => (
+
+
+
+
+
+ handleCustomQuote(e, index, 'quote')}
+ varient="outlined"
+ style={{ fontSize: '22px', fontWeight: 'bold' }}
+ />
+ handleCustomQuote(e, index, 'author')}
+ varient="outlined"
+ />
+
+
+
+
+
+
+ ))}
+
+ ) : (
+
+
+
+ {variables.getMessage(`${QUOTE_SECTION}.no_quotes`)}
+
+ {variables.getMessage('modals.main.settings.sections.message.add_some')}
+
+
+
+ )}
+ >
+ );
+}
+
+export default CustomSettings;
diff --git a/src/features/quote/options/QuoteOptions.jsx b/src/features/quote/options/QuoteOptions.jsx
index bea0a237..aa3381b1 100644
--- a/src/features/quote/options/QuoteOptions.jsx
+++ b/src/features/quote/options/QuoteOptions.jsx
@@ -1,7 +1,8 @@
import variables from 'config/variables';
-import React, { useState, useEffect } from 'react';
-import { MdCancel, MdAdd, MdSource, MdOutlineFormatQuote } from 'react-icons/md';
-import TextareaAutosize from '@mui/material/TextareaAutosize';
+
+import { useState, useEffect } from 'react';
+
+import { MdSource } from 'react-icons/md';
import {
Header,
@@ -12,59 +13,24 @@ import {
PreferencesWrapper,
} from 'components/Layout/Settings';
import { Checkbox, Dropdown } from 'components/Form/Settings';
-import { Button } from 'components/Elements';
+
import { useTab } from 'components/Elements/MainModal/backend/TabContext';
-import { toast } from 'react-toastify';
-import EventBus from 'utils/eventbus';
+import CustomSettings from './Custom';
+
import defaults from './default';
const QuoteOptions = () => {
- const [quoteType, setQuoteType] = useState(localStorage.getItem('quoteType') || defaults.quoteType);
- const [customQuote, setCustomQuote] = useState(getCustom());
- const [sourceSection, setSourceSection] = useState(false);
- const QUOTE_SECTION = 'modals.main.settings.sections.quote';
+ const [quoteType, setQuoteType] = useState(
+ localStorage.getItem('quoteType') || defaults.quoteType,
+ );
const { subSection } = useTab();
useEffect(() => {
localStorage.setItem('quoteType', quoteType);
}, [quoteType]);
- function resetCustom() {
- localStorage.setItem('customQuote', '[{"quote": "", "author": ""}]');
- setCustomQuote([{ quote: '', author: '' }]);
- toast(variables.getMessage('toasts.reset'));
- EventBus.emit('refresh', 'background');
- }
-
- function handleCustomQuote(e, index, type) {
- const result = e.target.value;
- const newCustomQuote = [...customQuote];
- newCustomQuote[index][type] = result;
- setCustomQuote(newCustomQuote);
- localStorage.setItem('customQuote', JSON.stringify(newCustomQuote));
- document.querySelector('.reminder-info').style.display = 'flex';
- localStorage.setItem('showReminder', true);
- }
-
- function modifyCustomQuote(type, index) {
- let newCustomQuote = [...customQuote];
- if (type === 'add') {
- newCustomQuote.push({ quote: '', author: '' });
- } else {
- newCustomQuote.splice(index, 1);
- }
- setCustomQuote(newCustomQuote);
- localStorage.setItem('customQuote', JSON.stringify(newCustomQuote));
- }
-
- function getCustom() {
- let data = JSON.parse(localStorage.getItem('customQuote'));
- if (data === null) {
- data = [];
- }
- return data;
- }
+ const QUOTE_SECTION = 'modals.main.settings.sections.quote';
const ButtonOptions = () => {
return (
@@ -139,92 +105,14 @@ const QuoteOptions = () => {
);
};
- let customSettings;
- if (quoteType === 'custom' && subSection === 'source') {
- customSettings = (
- <>
-
-
-
-
-
-
- {customQuote.length !== 0 ? (
-
- {customQuote.map((_url, index) => (
-
-
-
-
-
- handleCustomQuote(e, index, 'quote')}
- varient="outlined"
- style={{ fontSize: '22px', fontWeight: 'bold' }}
- />
- handleCustomQuote(e, index, 'author')}
- varient="outlined"
- />
-
-
-
-
-
-
- ))}
-
- ) : (
-
-
-
- {variables.getMessage(`${QUOTE_SECTION}.no_quotes`)}
-
- {variables.getMessage('modals.main.settings.sections.message.add_some')}
-
-
-
- )}
- >
- );
- } else {
- // api
- customSettings = <>>;
- }
-
return (
<>
{subSection === 'source' ? (