fix(live): keep channel search responsive (#25)
Filter projected live channels locally in the browser and apply server-side search and language filters before costly enrichment work. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@ -46,13 +46,9 @@ router.get('/channels', requireAuth, async (req, res) => {
|
||||
state = await liveProjection.startRebuild().promise;
|
||||
}
|
||||
const epgSources = await sources.getByType('epg');
|
||||
const allChannels = liveProjection.getChannels({ sourceId, includeHidden, userId: req.user.id, epgSources });
|
||||
const availableLanguages = [...new Map(allChannels.map(channel => [channel.language.code, channel.language])).values()]
|
||||
.map(language => ({ code: language.code, short: language.short, label: language.label }))
|
||||
.sort((left, right) => left.label.localeCompare(right.label));
|
||||
const channels = allChannels.filter(channel =>
|
||||
(!languages.length || languages.includes(channel.language.code)) && liveProjection.matchesSearch(channel, q)
|
||||
);
|
||||
const { channels, availableLanguages } = liveProjection.getChannelPage({
|
||||
sourceId, includeHidden, userId: req.user.id, epgSources, q, languages
|
||||
});
|
||||
return res.json({ projection: serializeState(state), filters: { availableLanguages }, channels });
|
||||
} catch (error) {
|
||||
console.error('[LiveProjection] Failed to serve projected channels:', error.message);
|
||||
|
||||
Reference in New Issue
Block a user