mirror of
https://github.com/Dispatcharr/Dispatcharr.git
synced 2026-01-23 02:35:14 +00:00
Enhancement: Add playlist and channel group fetching logic to StreamsTable for improved data management
This commit is contained in:
parent
f810142493
commit
0a340e51e2
1 changed files with 30 additions and 1 deletions
|
|
@ -182,6 +182,8 @@ const StreamsTable = ({ onReady }) => {
|
|||
const theme = useMantineTheme();
|
||||
const hasSignaledReady = useRef(false);
|
||||
const hasFetchedOnce = useRef(false);
|
||||
const hasFetchedPlaylists = useRef(false);
|
||||
const hasFetchedChannelGroups = useRef(false);
|
||||
|
||||
/**
|
||||
* useState
|
||||
|
|
@ -249,6 +251,8 @@ const StreamsTable = ({ onReady }) => {
|
|||
* Stores
|
||||
*/
|
||||
const playlists = usePlaylistsStore((s) => s.playlists);
|
||||
const fetchPlaylists = usePlaylistsStore((s) => s.fetchPlaylists);
|
||||
const playlistsLoading = usePlaylistsStore((s) => s.isLoading);
|
||||
|
||||
// Get direct access to channel groups without depending on other data
|
||||
const fetchChannelGroups = useChannelsStore((s) => s.fetchChannelGroups);
|
||||
|
|
@ -1048,11 +1052,15 @@ const StreamsTable = ({ onReady }) => {
|
|||
}, [fetchData]);
|
||||
|
||||
useEffect(() => {
|
||||
if (Object.keys(channelGroups).length > 0) {
|
||||
if (
|
||||
Object.keys(channelGroups).length > 0 ||
|
||||
hasFetchedChannelGroups.current
|
||||
) {
|
||||
return;
|
||||
}
|
||||
|
||||
const loadGroups = async () => {
|
||||
hasFetchedChannelGroups.current = true;
|
||||
try {
|
||||
await fetchChannelGroups();
|
||||
} catch (error) {
|
||||
|
|
@ -1063,6 +1071,27 @@ const StreamsTable = ({ onReady }) => {
|
|||
loadGroups();
|
||||
}, [channelGroups, fetchChannelGroups]);
|
||||
|
||||
useEffect(() => {
|
||||
if (
|
||||
playlists.length > 0 ||
|
||||
hasFetchedPlaylists.current ||
|
||||
playlistsLoading
|
||||
) {
|
||||
return;
|
||||
}
|
||||
|
||||
const loadPlaylists = async () => {
|
||||
hasFetchedPlaylists.current = true;
|
||||
try {
|
||||
await fetchPlaylists();
|
||||
} catch (error) {
|
||||
console.error('Error fetching playlists:', error);
|
||||
}
|
||||
};
|
||||
|
||||
loadPlaylists();
|
||||
}, [playlists, fetchPlaylists, playlistsLoading]);
|
||||
|
||||
useEffect(() => {
|
||||
const startItem = pagination.pageIndex * pagination.pageSize + 1;
|
||||
const endItem = Math.min(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue