import { useOutletContext } from 'react-router-dom'; import loadChannelList from '../api/loader/loadChannelList'; import iconGridView from '/img/icon-gridview.svg'; import iconListView from '/img/icon-listview.svg'; import iconAdd from '/img/icon-add.svg'; import { useEffect, useState } from 'react'; import Pagination, { PaginationType } from '../components/Pagination'; import { ConfigType } from './Home'; import { OutletContextType } from './Base'; import ChannelList from '../components/ChannelList'; import ScrollToTopOnNavigate from '../components/ScrollToTop'; import Notifications from '../components/Notifications'; import Button from '../components/Button'; import updateBulkChannelSubscriptions from '../api/actions/updateBulkChannelSubscriptions'; import useIsAdmin from '../functions/useIsAdmin'; import { useUserConfigStore } from '../stores/UserConfigStore'; import updateUserConfig, { UserConfigType } from '../api/actions/updateUserConfig'; type ChannelOverwritesType = { download_format?: string; autodelete_days?: number; index_playlists?: boolean; integrate_sponsorblock?: boolean | null; subscriptions_channel_size?: number; subscriptions_live_channel_size?: number; subscriptions_shorts_channel_size?: number; }; export type ChannelType = { channel_active: boolean; channel_banner_url: string; channel_description: string; channel_id: string; channel_last_refresh: string; channel_name: string; channel_overwrites?: ChannelOverwritesType; channel_subs: number; channel_subscribed: boolean; channel_tags: string[]; channel_thumb_url: string; channel_tvart_url: string; channel_views: number; }; type ChannelsListResponse = { data: ChannelType[]; paginate: PaginationType; config?: ConfigType; }; const Channels = () => { const { userConfig, setUserConfig } = useUserConfigStore(); const { currentPage, setCurrentPage } = useOutletContext() as OutletContextType; const isAdmin = useIsAdmin(); const [channelListResponse, setChannelListResponse] = useState(); const [showAddForm, setShowAddForm] = useState(false); const [refresh, setRefresh] = useState(true); const [showNotification, setShowNotification] = useState(false); const [channelsToSubscribeTo, setChannelsToSubscribeTo] = useState(''); const channels = channelListResponse?.data; const pagination = channelListResponse?.paginate; // const channelCount = pagination?.total_hits; const hasChannels = channels?.length !== 0; const handleUserConfigUpdate = async (config: Partial) => { const updatedUserConfig = await updateUserConfig(config); setUserConfig(updatedUserConfig); }; useEffect(() => { (async () => { const channelListResponse = await loadChannelList(currentPage, userConfig.show_subed_only); setChannelListResponse(channelListResponse); setShowNotification(false); setRefresh(false); })(); }, [refresh, userConfig.show_subed_only, currentPage, pagination?.current_page]); return ( <> TA | Channels

Channels

{isAdmin && (
{ setShowAddForm(!showAddForm); }} src={iconAdd} alt="add-icon" title="Subscribe to Channels" /> {showAddForm && (