mirror of
https://github.com/tubearchivist/tubearchivist.git
synced 2025-03-14 18:00:13 +00:00
fix null undefined types
This commit is contained in:
parent
f6b5de00df
commit
bf38cdc7f0
@ -2,27 +2,27 @@ import APIClient from '../../functions/APIClient';
|
|||||||
|
|
||||||
export type AppSettingsConfigType = {
|
export type AppSettingsConfigType = {
|
||||||
subscriptions: {
|
subscriptions: {
|
||||||
channel_size: number;
|
channel_size: number | null;
|
||||||
live_channel_size: number;
|
live_channel_size: number | null;
|
||||||
shorts_channel_size: number;
|
shorts_channel_size: number | null;
|
||||||
auto_start: boolean;
|
auto_start: boolean;
|
||||||
};
|
};
|
||||||
downloads: {
|
downloads: {
|
||||||
limit_speed: number | undefined;
|
limit_speed: number | null;
|
||||||
sleep_interval: number;
|
sleep_interval: number | null;
|
||||||
autodelete_days: number;
|
autodelete_days: number | null;
|
||||||
format: string | undefined;
|
format: string | null;
|
||||||
format_sort: string | undefined;
|
format_sort: string | null;
|
||||||
add_metadata: boolean;
|
add_metadata: boolean;
|
||||||
add_thumbnail: boolean;
|
add_thumbnail: boolean;
|
||||||
subtitle: string | undefined;
|
subtitle: string | null;
|
||||||
subtitle_source: boolean | string;
|
subtitle_source: string | null;
|
||||||
subtitle_index: boolean;
|
subtitle_index: boolean;
|
||||||
comment_max: string | undefined;
|
comment_max: string | null;
|
||||||
comment_sort: string;
|
comment_sort: string;
|
||||||
cookie_import: boolean;
|
cookie_import: boolean;
|
||||||
throttledratelimit: number | undefined;
|
throttledratelimit: number | null;
|
||||||
extractor_lang: string | undefined;
|
extractor_lang: string | null;
|
||||||
integrate_ryd: boolean;
|
integrate_ryd: boolean;
|
||||||
integrate_sponsorblock: boolean;
|
integrate_sponsorblock: boolean;
|
||||||
};
|
};
|
||||||
|
@ -5,7 +5,7 @@ type InputTextProps = {
|
|||||||
setValue:
|
setValue:
|
||||||
| React.Dispatch<React.SetStateAction<string | null>>
|
| React.Dispatch<React.SetStateAction<string | null>>
|
||||||
| React.Dispatch<React.SetStateAction<number | null>>;
|
| React.Dispatch<React.SetStateAction<number | null>>;
|
||||||
oldValue: string | number | undefined;
|
oldValue: string | number | null;
|
||||||
updateCallback: (arg0: string, arg1: string | boolean | number | null) => void;
|
updateCallback: (arg0: string, arg1: string | boolean | number | null) => void;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -36,9 +36,7 @@ const InputConfig = ({ type, name, value, setValue, oldValue, updateCallback }:
|
|||||||
<button onClick={() => setValue(oldValue as any)}>Cancel</button>
|
<button onClick={() => setValue(oldValue as any)}>Cancel</button>
|
||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
{oldValue !== undefined && (
|
{oldValue !== null && <button onClick={() => updateCallback(name, null)}>reset</button>}
|
||||||
<button onClick={() => updateCallback(name, null)}>reset</button>
|
|
||||||
)}
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
@ -60,16 +60,20 @@ const ChannelAbout = () => {
|
|||||||
const channelResponse = await loadChannelById(channelId);
|
const channelResponse = await loadChannelById(channelId);
|
||||||
|
|
||||||
setChannelResponse(channelResponse);
|
setChannelResponse(channelResponse);
|
||||||
setDownloadFormat(channelResponse?.data?.channel_overwrites?.download_format || null);
|
setDownloadFormat(channelResponse?.data?.channel_overwrites?.download_format ?? null);
|
||||||
setAutoDeleteAfter(channelResponse?.data?.channel_overwrites?.autodelete_days);
|
setAutoDeleteAfter(channelResponse?.data?.channel_overwrites?.autodelete_days ?? null);
|
||||||
setIndexPlaylists(channelResponse?.data?.channel_overwrites?.index_playlists || false);
|
setIndexPlaylists(channelResponse?.data?.channel_overwrites?.index_playlists ?? null);
|
||||||
setEnableSponsorblock(channelResponse?.data?.channel_overwrites?.integrate_sponsorblock);
|
setEnableSponsorblock(
|
||||||
setPageSizeVideo(channelResponse?.data?.channel_overwrites?.subscriptions_channel_size);
|
channelResponse?.data?.channel_overwrites?.integrate_sponsorblock ?? null,
|
||||||
|
);
|
||||||
|
setPageSizeVideo(
|
||||||
|
channelResponse?.data?.channel_overwrites?.subscriptions_channel_size ?? null,
|
||||||
|
);
|
||||||
setPageSizeShorts(
|
setPageSizeShorts(
|
||||||
channelResponse?.data?.channel_overwrites?.subscriptions_shorts_channel_size,
|
channelResponse?.data?.channel_overwrites?.subscriptions_shorts_channel_size ?? null,
|
||||||
);
|
);
|
||||||
setPageSizeStreams(
|
setPageSizeStreams(
|
||||||
channelResponse?.data?.channel_overwrites?.subscriptions_live_channel_size,
|
channelResponse?.data?.channel_overwrites?.subscriptions_live_channel_size ?? null,
|
||||||
);
|
);
|
||||||
|
|
||||||
setRefresh(false);
|
setRefresh(false);
|
||||||
@ -244,7 +248,7 @@ const ChannelAbout = () => {
|
|||||||
name="download_format"
|
name="download_format"
|
||||||
value={downloadFormat}
|
value={downloadFormat}
|
||||||
setValue={setDownloadFormat}
|
setValue={setDownloadFormat}
|
||||||
oldValue={channel.channel_overwrites?.download_format}
|
oldValue={channel.channel_overwrites?.download_format ?? null}
|
||||||
updateCallback={handleUpdateConfig}
|
updateCallback={handleUpdateConfig}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
@ -257,7 +261,7 @@ const ChannelAbout = () => {
|
|||||||
name="autodelete_days"
|
name="autodelete_days"
|
||||||
value={autoDeleteAfter}
|
value={autoDeleteAfter}
|
||||||
setValue={setAutoDeleteAfter}
|
setValue={setAutoDeleteAfter}
|
||||||
oldValue={channel.channel_overwrites?.autodelete_days}
|
oldValue={channel.channel_overwrites?.autodelete_days ?? null}
|
||||||
updateCallback={handleUpdateConfig}
|
updateCallback={handleUpdateConfig}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
@ -300,7 +304,7 @@ const ChannelAbout = () => {
|
|||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
{enableSponsorblock !== undefined ? (
|
{enableSponsorblock !== null ? (
|
||||||
<div className="toggle">
|
<div className="toggle">
|
||||||
<div className="toggleBox">
|
<div className="toggleBox">
|
||||||
<input
|
<input
|
||||||
@ -345,7 +349,7 @@ const ChannelAbout = () => {
|
|||||||
name="subscriptions_channel_size"
|
name="subscriptions_channel_size"
|
||||||
value={pageSizeVideo}
|
value={pageSizeVideo}
|
||||||
setValue={setPageSizeVideo}
|
setValue={setPageSizeVideo}
|
||||||
oldValue={channel.channel_overwrites?.subscriptions_channel_size}
|
oldValue={channel.channel_overwrites?.subscriptions_channel_size ?? null}
|
||||||
updateCallback={handleUpdateConfig}
|
updateCallback={handleUpdateConfig}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
@ -358,7 +362,7 @@ const ChannelAbout = () => {
|
|||||||
name="subscriptions_shorts_channel_size"
|
name="subscriptions_shorts_channel_size"
|
||||||
value={pageSizeShorts}
|
value={pageSizeShorts}
|
||||||
setValue={setPageSizeShorts}
|
setValue={setPageSizeShorts}
|
||||||
oldValue={channel.channel_overwrites?.subscriptions_shorts_channel_size}
|
oldValue={channel.channel_overwrites?.subscriptions_shorts_channel_size ?? null}
|
||||||
updateCallback={handleUpdateConfig}
|
updateCallback={handleUpdateConfig}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
@ -371,7 +375,7 @@ const ChannelAbout = () => {
|
|||||||
name="subscriptions_live_channel_size"
|
name="subscriptions_live_channel_size"
|
||||||
value={pageSizeStreams}
|
value={pageSizeStreams}
|
||||||
setValue={setPageSizeStreams}
|
setValue={setPageSizeStreams}
|
||||||
oldValue={channel.channel_overwrites?.subscriptions_live_channel_size}
|
oldValue={channel.channel_overwrites?.subscriptions_live_channel_size ?? null}
|
||||||
updateCallback={handleUpdateConfig}
|
updateCallback={handleUpdateConfig}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
@ -19,7 +19,7 @@ type ChannelOverwritesType = {
|
|||||||
download_format?: string;
|
download_format?: string;
|
||||||
autodelete_days?: number;
|
autodelete_days?: number;
|
||||||
index_playlists?: boolean;
|
index_playlists?: boolean;
|
||||||
integrate_sponsorblock?: boolean;
|
integrate_sponsorblock?: boolean | null;
|
||||||
subscriptions_channel_size?: number;
|
subscriptions_channel_size?: number;
|
||||||
subscriptions_live_channel_size?: number;
|
subscriptions_live_channel_size?: number;
|
||||||
subscriptions_shorts_channel_size?: number;
|
subscriptions_shorts_channel_size?: number;
|
||||||
|
@ -65,12 +65,12 @@ const SettingsApplication = () => {
|
|||||||
|
|
||||||
// Subtitles
|
// Subtitles
|
||||||
const [subtitleLang, setSubtitleLang] = useState<string | null>(null);
|
const [subtitleLang, setSubtitleLang] = useState<string | null>(null);
|
||||||
const [subtitleSource, setSubtitleSource] = useState('');
|
const [subtitleSource, setSubtitleSource] = useState<string | null>(null);
|
||||||
const [indexSubtitles, setIndexSubtitles] = useState(false);
|
const [indexSubtitles, setIndexSubtitles] = useState(false);
|
||||||
|
|
||||||
// Comments
|
// Comments
|
||||||
const [commentsMax, setCommentsMax] = useState<string | null>(null);
|
const [commentsMax, setCommentsMax] = useState<string | null>(null);
|
||||||
const [commentsSort, setCommentsSort] = useState('');
|
const [commentsSort, setCommentsSort] = useState<string>('');
|
||||||
|
|
||||||
// Cookie
|
// Cookie
|
||||||
// const [cookieImport, setCookieImport] = useState(false);
|
// const [cookieImport, setCookieImport] = useState(false);
|
||||||
@ -93,42 +93,42 @@ const SettingsApplication = () => {
|
|||||||
const apiToken = await loadApiToken();
|
const apiToken = await loadApiToken();
|
||||||
|
|
||||||
// Subscriptions
|
// Subscriptions
|
||||||
setVideoPageSize(appSettingsConfig?.subscriptions.channel_size);
|
setVideoPageSize(appSettingsConfig.subscriptions.channel_size);
|
||||||
setLivePageSize(appSettingsConfig?.subscriptions.live_channel_size);
|
setLivePageSize(appSettingsConfig.subscriptions.live_channel_size);
|
||||||
setShortPageSize(appSettingsConfig?.subscriptions.shorts_channel_size);
|
setShortPageSize(appSettingsConfig.subscriptions.shorts_channel_size);
|
||||||
setIsAutostart(appSettingsConfig?.subscriptions.auto_start);
|
setIsAutostart(appSettingsConfig.subscriptions.auto_start);
|
||||||
|
|
||||||
// Downloads
|
// Downloads
|
||||||
setCurrentDownloadSpeed(appSettingsConfig?.downloads.limit_speed || null);
|
setCurrentDownloadSpeed(appSettingsConfig.downloads.limit_speed);
|
||||||
setCurrentThrottledRate(appSettingsConfig?.downloads.throttledratelimit || null);
|
setCurrentThrottledRate(appSettingsConfig.downloads.throttledratelimit);
|
||||||
setCurrentScrapingSleep(appSettingsConfig?.downloads.sleep_interval);
|
setCurrentScrapingSleep(appSettingsConfig.downloads.sleep_interval);
|
||||||
setCurrentAutodelete(appSettingsConfig?.downloads.autodelete_days);
|
setCurrentAutodelete(appSettingsConfig.downloads.autodelete_days);
|
||||||
|
|
||||||
// Download Format
|
// Download Format
|
||||||
setDownloadsFormat(appSettingsConfig?.downloads.format || null);
|
setDownloadsFormat(appSettingsConfig.downloads.format);
|
||||||
setDownloadsFormatSort(appSettingsConfig?.downloads.format_sort || null);
|
setDownloadsFormatSort(appSettingsConfig.downloads.format_sort);
|
||||||
setDownloadsExtractorLang(appSettingsConfig?.downloads.extractor_lang || null);
|
setDownloadsExtractorLang(appSettingsConfig.downloads.extractor_lang);
|
||||||
setEmbedMetadata(appSettingsConfig?.downloads.add_metadata);
|
setEmbedMetadata(appSettingsConfig.downloads.add_metadata);
|
||||||
setEmbedThumbnail(appSettingsConfig?.downloads.add_thumbnail);
|
setEmbedThumbnail(appSettingsConfig.downloads.add_thumbnail);
|
||||||
|
|
||||||
// Subtitles
|
// Subtitles
|
||||||
setSubtitleLang(appSettingsConfig?.downloads.subtitle || null);
|
setSubtitleLang(appSettingsConfig.downloads.subtitle);
|
||||||
setSubtitleSource(appSettingsConfig?.downloads.subtitle_source.toString());
|
setSubtitleSource(appSettingsConfig.downloads.subtitle_source);
|
||||||
setIndexSubtitles(appSettingsConfig?.downloads.subtitle_index);
|
setIndexSubtitles(appSettingsConfig.downloads.subtitle_index);
|
||||||
|
|
||||||
// Comments
|
// Comments
|
||||||
setCommentsMax(appSettingsConfig?.downloads.comment_max || null);
|
setCommentsMax(appSettingsConfig.downloads.comment_max);
|
||||||
setCommentsSort(appSettingsConfig?.downloads.comment_sort);
|
setCommentsSort(appSettingsConfig.downloads.comment_sort);
|
||||||
|
|
||||||
// Cookie
|
// Cookie
|
||||||
// setCookieImport(appSettingsConfig?.downloads.cookie_import);
|
// setCookieImport(appSettingsConfig?.downloads.cookie_import);
|
||||||
|
|
||||||
// Integrations
|
// Integrations
|
||||||
setDownloadDislikes(appSettingsConfig?.downloads.integrate_ryd);
|
setDownloadDislikes(appSettingsConfig.downloads.integrate_ryd);
|
||||||
setEnableSponsorBlock(appSettingsConfig?.downloads.integrate_sponsorblock);
|
setEnableSponsorBlock(appSettingsConfig.downloads.integrate_sponsorblock);
|
||||||
|
|
||||||
// Snapshots
|
// Snapshots
|
||||||
setEnableSnapshots(appSettingsConfig?.application.enable_snapshot);
|
setEnableSnapshots(appSettingsConfig.application.enable_snapshot);
|
||||||
|
|
||||||
setResponse({
|
setResponse({
|
||||||
snapshots: snapshotResponse,
|
snapshots: snapshotResponse,
|
||||||
@ -166,6 +166,7 @@ const SettingsApplication = () => {
|
|||||||
<div className="title-bar">
|
<div className="title-bar">
|
||||||
<h1>Application Configurations</h1>
|
<h1>Application Configurations</h1>
|
||||||
</div>
|
</div>
|
||||||
|
{appSettingsConfig && (
|
||||||
<div className="info-box">
|
<div className="info-box">
|
||||||
<div className="info-box-item">
|
<div className="info-box-item">
|
||||||
<h2 id="subscriptions">Subscriptions</h2>
|
<h2 id="subscriptions">Subscriptions</h2>
|
||||||
@ -220,7 +221,10 @@ const SettingsApplication = () => {
|
|||||||
type="checkbox"
|
type="checkbox"
|
||||||
checked={isAutostart}
|
checked={isAutostart}
|
||||||
onChange={event => {
|
onChange={event => {
|
||||||
handleUpdateConfig('subscriptions.auto_start', event.target.checked || false);
|
handleUpdateConfig(
|
||||||
|
'subscriptions.auto_start',
|
||||||
|
event.target.checked || false,
|
||||||
|
);
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
{!isAutostart && (
|
{!isAutostart && (
|
||||||
@ -248,7 +252,7 @@ const SettingsApplication = () => {
|
|||||||
name="downloads.limit_speed"
|
name="downloads.limit_speed"
|
||||||
value={currentDownloadSpeed}
|
value={currentDownloadSpeed}
|
||||||
setValue={setCurrentDownloadSpeed}
|
setValue={setCurrentDownloadSpeed}
|
||||||
oldValue={appSettingsConfig?.downloads.limit_speed}
|
oldValue={appSettingsConfig.downloads.limit_speed}
|
||||||
updateCallback={handleUpdateConfig}
|
updateCallback={handleUpdateConfig}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
@ -261,7 +265,7 @@ const SettingsApplication = () => {
|
|||||||
name="downloads.throttledratelimit"
|
name="downloads.throttledratelimit"
|
||||||
value={currentThrottledRate}
|
value={currentThrottledRate}
|
||||||
setValue={setCurrentThrottledRate}
|
setValue={setCurrentThrottledRate}
|
||||||
oldValue={appSettingsConfig?.downloads.throttledratelimit}
|
oldValue={appSettingsConfig.downloads.throttledratelimit}
|
||||||
updateCallback={handleUpdateConfig}
|
updateCallback={handleUpdateConfig}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
@ -303,7 +307,7 @@ const SettingsApplication = () => {
|
|||||||
name="downloads.format"
|
name="downloads.format"
|
||||||
value={downloadsFormat}
|
value={downloadsFormat}
|
||||||
setValue={setDownloadsFormat}
|
setValue={setDownloadsFormat}
|
||||||
oldValue={appSettingsConfig?.downloads.format}
|
oldValue={appSettingsConfig.downloads.format}
|
||||||
updateCallback={handleUpdateConfig}
|
updateCallback={handleUpdateConfig}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
@ -316,7 +320,7 @@ const SettingsApplication = () => {
|
|||||||
name="downloads.format_sort"
|
name="downloads.format_sort"
|
||||||
value={downloadsFormatSort}
|
value={downloadsFormatSort}
|
||||||
setValue={setDownloadsFormatSort}
|
setValue={setDownloadsFormatSort}
|
||||||
oldValue={appSettingsConfig?.downloads.format_sort}
|
oldValue={appSettingsConfig.downloads.format_sort}
|
||||||
updateCallback={handleUpdateConfig}
|
updateCallback={handleUpdateConfig}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
@ -329,7 +333,7 @@ const SettingsApplication = () => {
|
|||||||
name="downloads.extractor_lang"
|
name="downloads.extractor_lang"
|
||||||
value={downloadsExtractorLang}
|
value={downloadsExtractorLang}
|
||||||
setValue={setDownloadsExtractorLang}
|
setValue={setDownloadsExtractorLang}
|
||||||
oldValue={appSettingsConfig?.downloads.extractor_lang}
|
oldValue={appSettingsConfig.downloads.extractor_lang}
|
||||||
updateCallback={handleUpdateConfig}
|
updateCallback={handleUpdateConfig}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
@ -371,7 +375,10 @@ const SettingsApplication = () => {
|
|||||||
type="checkbox"
|
type="checkbox"
|
||||||
checked={embedThumbnail}
|
checked={embedThumbnail}
|
||||||
onChange={event => {
|
onChange={event => {
|
||||||
handleUpdateConfig('downloads.add_thumbnail', event.target.checked || false);
|
handleUpdateConfig(
|
||||||
|
'downloads.add_thumbnail',
|
||||||
|
event.target.checked || false,
|
||||||
|
);
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
{!embedThumbnail && (
|
{!embedThumbnail && (
|
||||||
@ -567,7 +574,10 @@ const SettingsApplication = () => {
|
|||||||
type="checkbox"
|
type="checkbox"
|
||||||
checked={enableSponsorBlock}
|
checked={enableSponsorBlock}
|
||||||
onChange={event => {
|
onChange={event => {
|
||||||
handleUpdateConfig('downloads.integrate_sponsorblock', event.target.checked);
|
handleUpdateConfig(
|
||||||
|
'downloads.integrate_sponsorblock',
|
||||||
|
event.target.checked,
|
||||||
|
);
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
{!enableSponsorBlock && (
|
{!enableSponsorBlock && (
|
||||||
@ -654,7 +664,8 @@ const SettingsApplication = () => {
|
|||||||
}}
|
}}
|
||||||
/>{' '}
|
/>{' '}
|
||||||
Snapshot created on:{' '}
|
Snapshot created on:{' '}
|
||||||
<span className="settings-current">{snapshot.start_date}</span>, took{' '}
|
<span className="settings-current">{snapshot.start_date}</span>,
|
||||||
|
took{' '}
|
||||||
<span className="settings-current">{snapshot.duration_s}s</span> to
|
<span className="settings-current">{snapshot.duration_s}s</span> to
|
||||||
create. State: <i>{snapshot.state}</i>
|
create. State: <i>{snapshot.state}</i>
|
||||||
</p>
|
</p>
|
||||||
@ -667,6 +678,7 @@ const SettingsApplication = () => {
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<PaginationDummy />
|
<PaginationDummy />
|
||||||
|
Loading…
Reference in New Issue
Block a user