Adding toggle to Channel page to stop downloading comments for certain channels.

This commit is contained in:
Roland 2025-02-19 14:52:50 -07:00
parent 47d4d72bf8
commit 581d5eaf6e
No known key found for this signature in database
GPG key ID: 1BA620CE6C9A4680
20 changed files with 150 additions and 77 deletions

View file

@ -7,6 +7,7 @@ import {
ErrorMessage,
humanFileSize,
humanNumber,
InfoPopup,
SearchInput,
secondsToFrequency,
secondsToFullDuration,
@ -36,7 +37,7 @@ import {SortableTable} from "./SortableTable";
import {toast} from "react-semantic-toasts-2";
import {RecurringDownloadsTable} from "./admin/Downloads";
import {TagsContext, TagsSelector} from "../Tags";
import {InputForm} from "../hooks/useForm";
import {InputForm, ToggleForm} from "../hooks/useForm";
import {ChannelDownloadForm, DestinationForm, DownloadTagsSelector} from "./Download";
@ -123,6 +124,7 @@ export function ChannelPage({create, header}) {
name: channel.name,
directory: channel.directory,
url: channel.url,
download_missing_data: channel.download_missing_data,
};
let response = null;
@ -184,7 +186,7 @@ export function ChannelPage({create, header}) {
'name',
);
} else {
setErrorMessage('Invalid channel', 'Unable to save channel. See logs.');
setErrorMessage('Invalid channel', error.message || error.error || 'Unable to save channel. See logs.');
}
} else {
console.error('Did not get a response for channel!');
@ -327,6 +329,18 @@ export function ChannelPage({create, header}) {
</Grid.Row>;
}
const downloadMissingDataInfo = 'Automatically download missing comments, etc, in the background.';
const downloadMissingDataLabel = <>Download Missing Data<InfoPopup content={downloadMissingDataInfo}/></>;
const downloadMissingDataRow = <Grid.Row>
<Grid.Column>
<ToggleForm
form={form}
label={downloadMissingDataLabel}
path='download_missing_data'
/>
</Grid.Column>
</Grid.Row>;
let messageRow;
if (error || success) {
messageRow = <Grid.Row columns={1}>
@ -384,6 +398,7 @@ export function ChannelPage({create, header}) {
</Grid.Column>
</Grid.Row>
{channelTagRow}
{downloadMissingDataRow}
{!create && (channel.url || channel.rss_url) &&
<SimpleAccordion title='Details'>
<Grid>

View file

@ -467,6 +467,7 @@ export const useChannel = (channel_id) => {
directory: '',
url: '',
tag_name: null,
download_missing_data: null,
};
const fetchChannel = async () => {
@ -479,6 +480,7 @@ export const useChannel = (channel_id) => {
c['url'] = c['url'] || '';
c['download_frequency'] = c['download_frequency'] || '';
c['match_regex'] = c['match_regex'] || '';
c['download_missing_data'] = c['download_missing_data'] ?? true;
return c;
}
@ -487,6 +489,7 @@ export const useChannel = (channel_id) => {
name: form.formData.name,
directory: form.formData.directory,
url: form.formData.url,
download_missing_data: form.formData.download_missing_data,
};
if (channel_id) {

View file

@ -437,6 +437,7 @@ export function ToggleForm({form, name, label, path, icon = null, iconSize = 'bi
disabled={form.disabled}
name={name}
checked={inputProps.value}
onChange={inputProps.onChange}
/>
</FormInput>
}