Fixes streams being in incorrect order (for real this time)

This commit is contained in:
SergeantPanda 2025-04-25 10:59:56 -05:00
parent 7d0ea15924
commit 4c3ff1cdbd
2 changed files with 6 additions and 6 deletions

View file

@ -649,7 +649,8 @@ class ChannelProfileViewSet(viewsets.ModelViewSet):
class GetChannelStreamsAPIView(APIView):
def get(self, request, channel_id):
channel = get_object_or_404(Channel, id=channel_id)
streams = channel.streams
# Order the streams by channelstream__order to match the order in the channel view
streams = channel.streams.all().order_by('channelstream__order')
serializer = StreamSerializer(streams, many=True)
return Response(serializer.data)

View file

@ -98,14 +98,13 @@ const ChannelCard = ({ channel, clients, stopClient, stopChannel, logos, channel
if (channelId) {
const streamData = await API.getChannelStreams(channelId);
// Sort streams by ID to match the order in the channels view
const sortedStreamData = [...streamData].sort((a, b) => a.id - b.id);
setAvailableStreams(sortedStreamData);
// Use streams in the order returned by the API without sorting
setAvailableStreams(streamData);
// If we have a channel URL, try to find the matching stream
if (channel.url && sortedStreamData.length > 0) {
if (channel.url && streamData.length > 0) {
// Try to find matching stream based on URL
const matchingStream = sortedStreamData.find(stream =>
const matchingStream = streamData.find(stream =>
channel.url.includes(stream.url) || stream.url.includes(channel.url)
);