Skip to content

Add per-alias custom live group sort order#1143

Merged
sparkison merged 5 commits into
m3ue:devfrom
Warbs816:feat/alias-custom-live-group-sort
May 21, 2026
Merged

Add per-alias custom live group sort order#1143
sparkison merged 5 commits into
m3ue:devfrom
Warbs816:feat/alias-custom-live-group-sort

Conversation

@Warbs816
Copy link
Copy Markdown
Contributor

@Warbs816 Warbs816 commented May 21, 2026

Summary

Adds an optional per-alias custom sort order for live groups, plus a couple of related improvements to the group selector.

Today a playlist alias delivers its live groups to the client in the source playlist's order. This PR adds a "Sort groups in custom order" toggle (off by default) on the alias form. When it's on, a drag-to-reorder pane appears beneath the live group selection so you can set the exact order the selected groups are delivered in.

What's included

  • Custom live group order — a toggle plus a reorderable table pane under the live group selector. The order is stored per-alias in the existing group_filter JSON, so there's no migration. When enabled, getChannelQuery() ranks live groups by the saved order and falls back to the playlist's own sort_order for VOD and any groups not in the list, so the order is consistent across the M3U, EPG and Xtream output.
  • Custom group names in the selector — the selector, the selected chips, and the new sort pane now show a group's custom name when one is set, falling back to the source name.
  • Search matches the custom name too — group search now matches both the displayed (custom) name and the source name, case-insensitively. It uses LOWER(...) so it behaves correctly on PostgreSQL, whose LIKE is case-sensitive.

Scope is intentionally limited to live groups for now; VOD groups and series categories keep inheriting the source order.

Note / possible follow-up

The selector lists source groups (the provider groups created at import). Custom, user-created groups live in the groups table and aren't listed here, so they can't currently be selected or sorted per-alias — this matches existing behaviour. Happy to add them to the selector as a follow-up if that'd be useful.

Test plan

  • On an alias of a standard playlist, select some live groups and confirm they show their custom name where one is set.
  • Search the selector by both the custom name and the source name.
  • Turn on "Sort groups in custom order", drag the groups into a new order, save, and confirm the alias's playlist.m3u lists the groups in that order.
  • With the toggle off, confirm the alias keeps the source playlist's group order.

Warbs816 added 4 commits May 21, 2026 17:10
Adds an optional "Sort groups in custom order" toggle to playlist aliases
(default off). When enabled, a drag-to-reorder pane below the live group
selection lets you set the order the selected live groups are delivered to
the client, instead of inheriting the source playlist's group order.

- PlaylistAlias: hasCustomLiveGroupSort()/getLiveGroupSortOrder(), backed by
  new group_filter keys (sort_live_groups_custom, live_group_order) — no migration
- getChannelQuery(): ranks live groups by the alias order via a CASE on
  channels.group_internal, falling back to groups.sort_order for VOD and
  unlisted groups; applies consistently to M3U, EPG and Xtream output
- SourceGroupsTable + alias group selects now display the imported group's
  custom name when one exists, falling back to the source name
The custom search closure on the source-group selector used `LIKE`, which is
case-sensitive on PostgreSQL, so terms that didn't match the stored casing
returned nothing (e.g. "enter" missed "Entertainment", "doc" missed
"Documentaries"). SQLite/MySQL hid this because their LIKE is case-insensitive.

Revert search and sort to Filament's default on the real source_groups.name
column (case-insensitive across databases) and resolve the imported group's
custom name via a correlated subquery for display only — instead of a join,
which also made the `name` column ambiguous. Adds a Postgres-shaped regression
test driving the table through a Livewire harness.
Group search now also matches the displayed (custom) name, not just the source
name, so a group renamed away from its source — e.g. source "GENERAL hevc" shown
as "Entertainment" — is found when searching either term. Implemented with an
EXISTS subquery against the imported group, using LOWER(...) on both sides to
stay case-insensitive on PostgreSQL.
@Warbs816 Warbs816 marked this pull request as ready for review May 21, 2026 17:33
@sparkison sparkison requested a review from Copilot May 21, 2026 18:00

This comment was marked as resolved.

Address Copilot review on m3ue#1143. Both the selector's custom-name search
subquery and the live-group sort pane's label lookup matched groups by
name_internal + playlist alone, so a group of a different type sharing the
same name_internal could leak into search results or supply the wrong label.

- SourceGroupsTable: tie the custom-name EXISTS subquery to source_groups.type
- buildLiveGroupSortItems: constrain the label lookup to live groups

Add regression tests for both cross-type cases.
@sparkison sparkison merged commit c1c6e64 into m3ue:dev May 21, 2026
4 checks passed
@Warbs816 Warbs816 deleted the feat/alias-custom-live-group-sort branch May 21, 2026 22:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants