mirror of
https://github.com/Dispatcharr/Dispatcharr.git
synced 2026-07-20 01:59:50 +00:00
Refactor ChannelsTable row styling logic to use memoized class mapping for improved performance and readability.
This commit is contained in:
parent
c005a48162
commit
1e629d57ec
1 changed files with 15 additions and 14 deletions
|
|
@ -269,6 +269,19 @@ const ChannelsTable = ({ onReady }) => {
|
|||
// store/channelsTable
|
||||
const data = useChannelsTableStore((s) => s.channels);
|
||||
const pageCount = useChannelsTableStore((s) => s.pageCount);
|
||||
|
||||
const rowClassMap = useMemo(() => {
|
||||
const map = {};
|
||||
for (const channel of data) {
|
||||
const hasStreams = channel.streams?.length > 0;
|
||||
if (!hasStreams) {
|
||||
map[channel.id] = 'no-streams-row';
|
||||
} else if (channel.streams.some((s) => s.is_stale)) {
|
||||
map[channel.id] = 'partially-stale-streams-row';
|
||||
}
|
||||
}
|
||||
return map;
|
||||
}, [data]);
|
||||
const setSelectedChannelIds = useChannelsTableStore(
|
||||
(s) => s.setSelectedChannelIds
|
||||
);
|
||||
|
|
@ -1130,20 +1143,8 @@ const ChannelsTable = ({ onReady }) => {
|
|||
epg: renderHeaderCell,
|
||||
},
|
||||
getRowStyles: (row) => {
|
||||
const hasStreams =
|
||||
row.original.streams && row.original.streams.length > 0;
|
||||
const hasStaleStreams =
|
||||
hasStreams && row.original.streams.some((s) => s.is_stale);
|
||||
|
||||
if (!hasStreams) {
|
||||
return { className: 'no-streams-row' };
|
||||
}
|
||||
|
||||
if (hasStaleStreams) {
|
||||
return { className: 'partially-stale-streams-row' };
|
||||
}
|
||||
|
||||
return {};
|
||||
const cls = rowClassMap[row.original.id];
|
||||
return cls ? { className: cls } : {};
|
||||
},
|
||||
});
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue