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 theme = useMantineTheme();
|
||||||
const hasSignaledReady = useRef(false);
|
const hasSignaledReady = useRef(false);
|
||||||
const hasFetchedOnce = useRef(false);
|
const hasFetchedOnce = useRef(false);
|
||||||
|
const hasFetchedPlaylists = useRef(false);
|
||||||
|
const hasFetchedChannelGroups = useRef(false);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* useState
|
* useState
|
||||||
|
|
@ -249,6 +251,8 @@ const StreamsTable = ({ onReady }) => {
|
||||||
* Stores
|
* Stores
|
||||||
*/
|
*/
|
||||||
const playlists = usePlaylistsStore((s) => s.playlists);
|
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
|
// Get direct access to channel groups without depending on other data
|
||||||
const fetchChannelGroups = useChannelsStore((s) => s.fetchChannelGroups);
|
const fetchChannelGroups = useChannelsStore((s) => s.fetchChannelGroups);
|
||||||
|
|
@ -1048,11 +1052,15 @@ const StreamsTable = ({ onReady }) => {
|
||||||
}, [fetchData]);
|
}, [fetchData]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (Object.keys(channelGroups).length > 0) {
|
if (
|
||||||
|
Object.keys(channelGroups).length > 0 ||
|
||||||
|
hasFetchedChannelGroups.current
|
||||||
|
) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const loadGroups = async () => {
|
const loadGroups = async () => {
|
||||||
|
hasFetchedChannelGroups.current = true;
|
||||||
try {
|
try {
|
||||||
await fetchChannelGroups();
|
await fetchChannelGroups();
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
|
@ -1063,6 +1071,27 @@ const StreamsTable = ({ onReady }) => {
|
||||||
loadGroups();
|
loadGroups();
|
||||||
}, [channelGroups, fetchChannelGroups]);
|
}, [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(() => {
|
useEffect(() => {
|
||||||
const startItem = pagination.pageIndex * pagination.pageSize + 1;
|
const startItem = pagination.pageIndex * pagination.pageSize + 1;
|
||||||
const endItem = Math.min(
|
const endItem = Math.min(
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue