mirror of
https://github.com/mue/mue.git
synced 2026-07-20 23:44:07 +02:00
feat: add update frequency settings for quotes and backgrounds
- Introduced frequency settings for quotes and background updates in multiple languages. - Added new localization keys for "Update Frequency" and its options. - Implemented a new hook `useFrequencyInterval` to manage update intervals based on user settings. - Created a `frequencyManager` utility to handle frequency intervals and update logic. - Updated default settings to include frequency preferences for both quotes and backgrounds.
This commit is contained in:
@@ -12,6 +12,7 @@ import {
|
||||
} from 'components/Layout/Settings';
|
||||
import { Checkbox, Dropdown, Textarea } from 'components/Form/Settings';
|
||||
import { Button } from 'components/Elements';
|
||||
import { FREQUENCY_OPTIONS } from 'utils/frequencyManager';
|
||||
|
||||
const QuoteOptions = ({ currentSubSection, onSubSectionChange, sectionName }) => {
|
||||
const getCustom = () => {
|
||||
@@ -123,6 +124,39 @@ const QuoteOptions = ({ currentSubSection, onSubSectionChange, sectionName }) =>
|
||||
);
|
||||
};
|
||||
|
||||
const FrequencyOptions = () => {
|
||||
return (
|
||||
<Row>
|
||||
<Content
|
||||
title={variables.getMessage(`${QUOTE_SECTION}.frequency.title`)}
|
||||
subtitle={variables.getMessage(`${QUOTE_SECTION}.frequency.subtitle`)}
|
||||
/>
|
||||
<Action>
|
||||
<Dropdown
|
||||
name="quoteFrequency"
|
||||
label={variables.getMessage(`${QUOTE_SECTION}.frequency.title`)}
|
||||
onChange={(value) => {
|
||||
localStorage.setItem('quoteStartTime', Date.now());
|
||||
// Clear queue if switching from refresh to time-based frequency
|
||||
const oldValue = localStorage.getItem('quoteFrequency');
|
||||
if (oldValue === 'refresh' && value !== 'refresh') {
|
||||
localStorage.removeItem('quoteQueue');
|
||||
}
|
||||
// Notify the frequency interval hook that the frequency changed
|
||||
window.dispatchEvent(new CustomEvent('frequencyChanged', {
|
||||
detail: { type: 'quote' }
|
||||
}));
|
||||
}}
|
||||
items={FREQUENCY_OPTIONS.map((opt) => ({
|
||||
value: opt.value,
|
||||
text: variables.getMessage(opt.text),
|
||||
}))}
|
||||
/>
|
||||
</Action>
|
||||
</Row>
|
||||
);
|
||||
};
|
||||
|
||||
const AdditionalOptions = () => {
|
||||
return (
|
||||
<Row final={true}>
|
||||
@@ -282,6 +316,7 @@ const QuoteOptions = ({ currentSubSection, onSubSectionChange, sectionName }) =>
|
||||
<SourceDropdown />
|
||||
</Section>
|
||||
<ButtonOptions />
|
||||
<FrequencyOptions />
|
||||
<AdditionalOptions />
|
||||
</PreferencesWrapper>
|
||||
)}
|
||||
|
||||
Reference in New Issue
Block a user