mirror of
https://github.com/Dispatcharr/Dispatcharr.git
synced 2026-07-28 12:36:42 +00:00
Reset page number to 1 when changing filters to avoid page errors.
This commit is contained in:
parent
e65fd59a49
commit
c41d948fc9
2 changed files with 38 additions and 7 deletions
|
|
@ -321,15 +321,28 @@ const ChannelsTable = ({ }) => {
|
|||
e.stopPropagation();
|
||||
}, []);
|
||||
|
||||
const handleFilterChange = useCallback((e) => {
|
||||
// Remove useCallback to ensure we're using the latest setPagination function
|
||||
const handleFilterChange = (e) => {
|
||||
const { name, value } = e.target;
|
||||
// First reset pagination to page 0
|
||||
setPagination({
|
||||
...pagination,
|
||||
pageIndex: 0,
|
||||
});
|
||||
// Then update filters
|
||||
setFilters((prev) => ({
|
||||
...prev,
|
||||
[name]: value,
|
||||
}));
|
||||
}, []);
|
||||
};
|
||||
|
||||
const handleGroupChange = (value) => {
|
||||
// First reset pagination to page 0
|
||||
setPagination({
|
||||
...pagination,
|
||||
pageIndex: 0,
|
||||
});
|
||||
// Then update filters
|
||||
setFilters((prev) => ({
|
||||
...prev,
|
||||
channel_group: value ? value : '',
|
||||
|
|
|
|||
|
|
@ -169,7 +169,7 @@ const StreamRowActions = ({
|
|||
);
|
||||
};
|
||||
|
||||
const StreamsTable = ({}) => {
|
||||
const StreamsTable = ({ }) => {
|
||||
const theme = useMantineTheme();
|
||||
|
||||
/**
|
||||
|
|
@ -300,6 +300,12 @@ const StreamsTable = ({}) => {
|
|||
...prev,
|
||||
[name]: value,
|
||||
}));
|
||||
|
||||
// Reset to first page whenever filters change to avoid "Invalid page" errors
|
||||
setPagination((prev) => ({
|
||||
...prev,
|
||||
pageIndex: 0,
|
||||
}));
|
||||
};
|
||||
|
||||
const handleGroupChange = (value) => {
|
||||
|
|
@ -307,6 +313,12 @@ const StreamsTable = ({}) => {
|
|||
...prev,
|
||||
channel_group: value ? value : '',
|
||||
}));
|
||||
|
||||
// Reset to first page whenever filters change to avoid "Invalid page" errors
|
||||
setPagination((prev) => ({
|
||||
...prev,
|
||||
pageIndex: 0,
|
||||
}));
|
||||
};
|
||||
|
||||
const handleM3UChange = (value) => {
|
||||
|
|
@ -314,6 +326,12 @@ const StreamsTable = ({}) => {
|
|||
...prev,
|
||||
m3u_account: value ? value : '',
|
||||
}));
|
||||
|
||||
// Reset to first page whenever filters change to avoid "Invalid page" errors
|
||||
setPagination((prev) => ({
|
||||
...prev,
|
||||
pageIndex: 0,
|
||||
}));
|
||||
};
|
||||
|
||||
const fetchData = useCallback(async () => {
|
||||
|
|
@ -638,10 +656,10 @@ const StreamsTable = ({}) => {
|
|||
style={
|
||||
selectedStreamIds.length > 0 && selectedChannelIds.length === 1
|
||||
? {
|
||||
borderWidth: '1px',
|
||||
borderColor: theme.tailwind.green[5],
|
||||
color: 'white',
|
||||
}
|
||||
borderWidth: '1px',
|
||||
borderColor: theme.tailwind.green[5],
|
||||
color: 'white',
|
||||
}
|
||||
: undefined
|
||||
}
|
||||
disabled={
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue