Feature/handle disabled download ahead limit by default (#475)
* Add a description to the dialog * Set the default limit to the lowest possible value
This commit is contained in:
@@ -10,7 +10,7 @@ import Dialog from '@mui/material/Dialog';
|
|||||||
import DialogContent from '@mui/material/DialogContent';
|
import DialogContent from '@mui/material/DialogContent';
|
||||||
import DialogTitle from '@mui/material/DialogTitle';
|
import DialogTitle from '@mui/material/DialogTitle';
|
||||||
import TextField from '@mui/material/TextField';
|
import TextField from '@mui/material/TextField';
|
||||||
import { InputAdornment, ListItemText } from '@mui/material';
|
import { InputAdornment, ListItemText, Stack, Typography } from '@mui/material';
|
||||||
import DialogActions from '@mui/material/DialogActions';
|
import DialogActions from '@mui/material/DialogActions';
|
||||||
import Button from '@mui/material/Button';
|
import Button from '@mui/material/Button';
|
||||||
import { useCallback, useEffect, useState } from 'react';
|
import { useCallback, useEffect, useState } from 'react';
|
||||||
@@ -19,6 +19,8 @@ import ListItemButton from '@mui/material/ListItemButton';
|
|||||||
import * as React from 'react';
|
import * as React from 'react';
|
||||||
import ListItemIcon from '@mui/material/ListItemIcon';
|
import ListItemIcon from '@mui/material/ListItemIcon';
|
||||||
import Slider from '@mui/material/Slider';
|
import Slider from '@mui/material/Slider';
|
||||||
|
import DialogContentText from '@mui/material/DialogContentText';
|
||||||
|
import InfoIcon from '@mui/icons-material/Info';
|
||||||
|
|
||||||
type BaseProps = {
|
type BaseProps = {
|
||||||
settingTitle: string;
|
settingTitle: string;
|
||||||
@@ -30,6 +32,8 @@ type BaseProps = {
|
|||||||
maxValue?: number;
|
maxValue?: number;
|
||||||
stepSize?: number;
|
stepSize?: number;
|
||||||
dialogTitle: string;
|
dialogTitle: string;
|
||||||
|
dialogDescription?: string;
|
||||||
|
dialogDisclaimer?: string;
|
||||||
valueUnit: string;
|
valueUnit: string;
|
||||||
handleUpdate: (value: number) => void;
|
handleUpdate: (value: number) => void;
|
||||||
showSlider?: never;
|
showSlider?: never;
|
||||||
@@ -45,6 +49,8 @@ export const NumberSetting = ({
|
|||||||
settingTitle,
|
settingTitle,
|
||||||
settingValue,
|
settingValue,
|
||||||
settingIcon,
|
settingIcon,
|
||||||
|
dialogDescription,
|
||||||
|
dialogDisclaimer,
|
||||||
value,
|
value,
|
||||||
defaultValue,
|
defaultValue,
|
||||||
minValue,
|
minValue,
|
||||||
@@ -108,6 +114,35 @@ export const NumberSetting = ({
|
|||||||
<Dialog open={isDialogOpen} onClose={closeDialogWithReset}>
|
<Dialog open={isDialogOpen} onClose={closeDialogWithReset}>
|
||||||
<DialogContent>
|
<DialogContent>
|
||||||
<DialogTitle sx={{ paddingLeft: 0 }}>{dialogTitle}</DialogTitle>
|
<DialogTitle sx={{ paddingLeft: 0 }}>{dialogTitle}</DialogTitle>
|
||||||
|
{(!!dialogDescription || !!dialogDisclaimer) && (
|
||||||
|
<DialogContentText sx={{ paddingBottom: '10px' }} component="div">
|
||||||
|
{dialogDescription && (
|
||||||
|
<Typography
|
||||||
|
variant="body1"
|
||||||
|
sx={{
|
||||||
|
whiteSpace: 'pre-line',
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
{dialogDescription}
|
||||||
|
</Typography>
|
||||||
|
)}
|
||||||
|
{dialogDisclaimer && (
|
||||||
|
<Stack direction="row" alignItems="center">
|
||||||
|
<InfoIcon color="warning" />
|
||||||
|
<Typography
|
||||||
|
variant="body1"
|
||||||
|
sx={{
|
||||||
|
marginLeft: '10px',
|
||||||
|
marginTop: '5px',
|
||||||
|
whiteSpace: 'pre-line',
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
{dialogDisclaimer}
|
||||||
|
</Typography>
|
||||||
|
</Stack>
|
||||||
|
)}
|
||||||
|
</DialogContentText>
|
||||||
|
)}
|
||||||
<TextField
|
<TextField
|
||||||
sx={{
|
sx={{
|
||||||
width: '100%',
|
width: '100%',
|
||||||
|
|||||||
@@ -125,11 +125,6 @@ export const SelectSetting = <SettingValue extends string | number>({
|
|||||||
)}
|
)}
|
||||||
</DialogContentText>
|
</DialogContentText>
|
||||||
)}
|
)}
|
||||||
{/* {!!dialogValueDisplayInfo.disclaimer && ( */}
|
|
||||||
{/* <DialogContentText sx={{ paddingBottom: '10px', color: 'orange' }}> */}
|
|
||||||
{/* {t(dialogValueDisplayInfo.disclaimer)} */}
|
|
||||||
{/* </DialogContentText> */}
|
|
||||||
{/* )} */}
|
|
||||||
<FormControl fullWidth>
|
<FormControl fullWidth>
|
||||||
<Select
|
<Select
|
||||||
id="dialog-select"
|
id="dialog-select"
|
||||||
|
|||||||
@@ -14,9 +14,9 @@ import { requestManager } from '@/lib/requests/RequestManager.ts';
|
|||||||
import { NumberSetting } from '@/components/settings/NumberSetting.tsx';
|
import { NumberSetting } from '@/components/settings/NumberSetting.tsx';
|
||||||
import { getPersistedServerSetting, usePersistedValue } from '@/util/usePersistedValue.tsx';
|
import { getPersistedServerSetting, usePersistedValue } from '@/util/usePersistedValue.tsx';
|
||||||
|
|
||||||
const DEFAULT_LIMIT = 5;
|
|
||||||
const MIN_LIMIT = 2;
|
const MIN_LIMIT = 2;
|
||||||
const MAX_LIMIT = 10;
|
const MAX_LIMIT = 10;
|
||||||
|
const DEFAULT_LIMIT = MIN_LIMIT;
|
||||||
|
|
||||||
export const DownloadAheadSetting = () => {
|
export const DownloadAheadSetting = () => {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
@@ -75,6 +75,8 @@ export const DownloadAheadSetting = () => {
|
|||||||
defaultValue={DEFAULT_LIMIT}
|
defaultValue={DEFAULT_LIMIT}
|
||||||
showSlider
|
showSlider
|
||||||
dialogTitle={t('download.settings.download_ahead.label.unread_chapters_to_download')}
|
dialogTitle={t('download.settings.download_ahead.label.unread_chapters_to_download')}
|
||||||
|
dialogDescription={t('download.settings.download_ahead.label.description')}
|
||||||
|
dialogDisclaimer={t('download.settings.download_ahead.label.disclaimer')}
|
||||||
valueUnit={t('chapter.title')}
|
valueUnit={t('chapter.title')}
|
||||||
handleUpdate={updateSetting}
|
handleUpdate={updateSetting}
|
||||||
disabled={!shouldDownloadAhead}
|
disabled={!shouldDownloadAhead}
|
||||||
|
|||||||
@@ -159,6 +159,8 @@
|
|||||||
},
|
},
|
||||||
"download_ahead": {
|
"download_ahead": {
|
||||||
"label": {
|
"label": {
|
||||||
|
"description": "How many chapters should get downloaded when marking a chapter as read while reading.",
|
||||||
|
"disclaimer": "This limit will also be applied to the automatic download of new chapters during an update",
|
||||||
"unread_chapters_to_download": "Number of unread chapters to download",
|
"unread_chapters_to_download": "Number of unread chapters to download",
|
||||||
"value": "{{chapters}} $t(chapter.title)",
|
"value": "{{chapters}} $t(chapter.title)",
|
||||||
"while_reading": "Auto download while reading"
|
"while_reading": "Auto download while reading"
|
||||||
|
|||||||
Reference in New Issue
Block a user