mirror of
https://github.com/Dispatcharr/Dispatcharr.git
synced 2026-07-28 12:36:42 +00:00
Refactor channel selection handling to use table state and clear selection on data change
This commit is contained in:
parent
f6339b691c
commit
65e0be80e0
1 changed files with 17 additions and 3 deletions
|
|
@ -375,7 +375,9 @@ const ChannelsTable = ({ }) => {
|
|||
};
|
||||
|
||||
const editChannel = async (ch = null) => {
|
||||
if (selectedChannelIds.length > 0) {
|
||||
// Use table's selected state instead of store state to avoid stale selections
|
||||
const currentSelection = table ? table.getState().selectedTableIds : [];
|
||||
if (currentSelection.length > 1) {
|
||||
setChannelBatchModalOpen(true);
|
||||
} else {
|
||||
setChannel(ch);
|
||||
|
|
@ -611,7 +613,7 @@ const ChannelsTable = ({ }) => {
|
|||
setHDHRUrl(`${hdhrUrlBase}${profileString}`);
|
||||
setEPGUrl(`${epgUrlBase}${profileString}`);
|
||||
setM3UUrl(`${m3uUrlBase}${profileString}`);
|
||||
}, [selectedProfileId]);
|
||||
}, [selectedProfileId, profiles]);
|
||||
|
||||
useEffect(() => {
|
||||
const startItem = pagination.pageIndex * pagination.pageSize + 1; // +1 to start from 1, not 0
|
||||
|
|
@ -620,7 +622,19 @@ const ChannelsTable = ({ }) => {
|
|||
totalCount
|
||||
);
|
||||
setPaginationString(`${startItem} to ${endItem} of ${totalCount}`);
|
||||
}, [data]);
|
||||
}, [pagination.pageIndex, pagination.pageSize, totalCount]);
|
||||
|
||||
// Clear selection when data changes (e.g., when navigating back to the page)
|
||||
useEffect(() => {
|
||||
setSelectedChannelIds([]);
|
||||
}, [data, setSelectedChannelIds]);
|
||||
|
||||
// Clear selection when component unmounts
|
||||
useEffect(() => {
|
||||
return () => {
|
||||
setSelectedChannelIds([]);
|
||||
};
|
||||
}, [setSelectedChannelIds]);
|
||||
|
||||
const columns = useMemo(
|
||||
() => [
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue