mirror of
https://github.com/Dispatcharr/Dispatcharr.git
synced 2026-07-22 09:37:57 +00:00
Merge branch 'dev' of https://github.com/Dispatcharr/Dispatcharr into dev
This commit is contained in:
commit
70265455cf
6 changed files with 33 additions and 15 deletions
|
|
@ -174,14 +174,14 @@ class ChannelSerializer(serializers.ModelSerializer):
|
|||
return StreamSerializer(obj.streams.all().order_by('channelstream__order'), many=True).data
|
||||
|
||||
def create(self, validated_data):
|
||||
stream_ids = validated_data.pop('streams', [])
|
||||
streams = validated_data.pop('streams', [])
|
||||
channel_number = validated_data.pop('channel_number', Channel.get_next_available_channel_number())
|
||||
validated_data["channel_number"] = channel_number
|
||||
channel = Channel.objects.create(**validated_data)
|
||||
|
||||
# Add streams in the specified order
|
||||
for index, stream_id in enumerate(stream_ids):
|
||||
ChannelStream.objects.create(channel=channel, stream_id=stream_id, order=index)
|
||||
for index, stream in enumerate(streams):
|
||||
ChannelStream.objects.create(channel=channel, stream_id=stream.id, order=index)
|
||||
|
||||
return channel
|
||||
|
||||
|
|
|
|||
|
|
@ -192,13 +192,17 @@ export default class API {
|
|||
|
||||
static async requeryChannels() {
|
||||
try {
|
||||
const response = await request(
|
||||
`${host}/api/channels/channels/?${API.lastQueryParams.toString()}`
|
||||
);
|
||||
const [response, ids] = await Promise.all([
|
||||
request(
|
||||
`${host}/api/channels/channels/?${API.lastQueryParams.toString()}`
|
||||
),
|
||||
API.getAllChannelIds(API.lastQueryParams),
|
||||
]);
|
||||
|
||||
useChannelsTableStore
|
||||
.getState()
|
||||
.queryChannels(response, API.lastQueryParams);
|
||||
useChannelsTableStore.getState().setAllQueryIds(ids);
|
||||
|
||||
return response;
|
||||
} catch (e) {
|
||||
|
|
|
|||
|
|
@ -199,6 +199,8 @@ const ChannelsTable = ({}) => {
|
|||
const setSorting = useChannelsTableStore((s) => s.setSorting);
|
||||
const totalCount = useChannelsTableStore((s) => s.totalCount);
|
||||
const setChannelStreams = useChannelsTableStore((s) => s.setChannelStreams);
|
||||
const allRowIds = useChannelsTableStore((s) => s.allQueryIds);
|
||||
const setAllRowIds = useChannelsTableStore((s) => s.setAllQueryIds);
|
||||
|
||||
// store/channels
|
||||
const channels = useChannelsStore((s) => s.channels);
|
||||
|
|
@ -228,7 +230,6 @@ const ChannelsTable = ({}) => {
|
|||
/**
|
||||
* useState
|
||||
*/
|
||||
const [allRowIds, setAllRowIds] = useState([]);
|
||||
const [channel, setChannel] = useState(null);
|
||||
const [channelModalOpen, setChannelModalOpen] = useState(false);
|
||||
const [recordingModalOpen, setRecordingModalOpen] = useState(false);
|
||||
|
|
|
|||
|
|
@ -52,7 +52,7 @@ const StreamRowActions = ({
|
|||
handleWatchStream,
|
||||
selectedChannelIds,
|
||||
}) => {
|
||||
const channelSelectionStreamIds = useChannelsTableStore(
|
||||
const channelSelectionStreams = useChannelsTableStore(
|
||||
(state) =>
|
||||
state.channels.find((chan) => chan.id === selectedChannelIds[0])?.streams
|
||||
);
|
||||
|
|
@ -72,7 +72,9 @@ const StreamRowActions = ({
|
|||
await API.updateChannel({
|
||||
id: selectedChannelIds[0],
|
||||
streams: [
|
||||
...new Set(channelSelectionStreamIds.concat([row.original.id])),
|
||||
...new Set(
|
||||
channelSelectionStreams.map((s) => s.id).concat([row.original.id])
|
||||
),
|
||||
],
|
||||
});
|
||||
await API.requeryChannels();
|
||||
|
|
@ -101,8 +103,10 @@ const StreamRowActions = ({
|
|||
style={{ background: 'none' }}
|
||||
disabled={
|
||||
selectedChannelIds.length !== 1 ||
|
||||
(channelSelectionStreamIds &&
|
||||
channelSelectionStreamIds.includes(row.original.id))
|
||||
(channelSelectionStreams &&
|
||||
channelSelectionStreams
|
||||
.map((s) => s.id)
|
||||
.includes(row.original.id))
|
||||
}
|
||||
>
|
||||
<ListPlus size="18" fontSize="small" />
|
||||
|
|
@ -192,7 +196,7 @@ const StreamsTable = ({}) => {
|
|||
const channelGroups = useChannelsStore((s) => s.channelGroups);
|
||||
const selectedChannelIds = useChannelsTableStore((s) => s.selectedChannelIds);
|
||||
const fetchLogos = useChannelsStore((s) => s.fetchLogos);
|
||||
const channelSelectionStreamIds = useChannelsTableStore(
|
||||
const channelSelectionStreams = useChannelsTableStore(
|
||||
(state) =>
|
||||
state.channels.find((chan) => chan.id === selectedChannelIds[0])?.streams
|
||||
);
|
||||
|
|
@ -385,7 +389,9 @@ const StreamsTable = ({}) => {
|
|||
await API.updateChannel({
|
||||
id: selectedChannelIds[0],
|
||||
streams: [
|
||||
...new Set(channelSelectionStreamIds.concat(selectedStreamIds)),
|
||||
...new Set(
|
||||
channelSelectionStreams.map((s) => s.id).concat(selectedStreamIds)
|
||||
),
|
||||
],
|
||||
});
|
||||
await API.requeryChannels();
|
||||
|
|
@ -536,7 +542,7 @@ const StreamsTable = ({}) => {
|
|||
);
|
||||
}
|
||||
},
|
||||
[selectedChannelIds, channelSelectionStreamIds]
|
||||
[selectedChannelIds, channelSelectionStreams]
|
||||
);
|
||||
|
||||
const table = useTable({
|
||||
|
|
|
|||
|
|
@ -13,6 +13,7 @@ const useChannelsTableStore = create((set, get) => ({
|
|||
pageSize: 50,
|
||||
},
|
||||
selectedChannelIds: [],
|
||||
allQueryIds: [],
|
||||
|
||||
queryChannels: ({ results, count }, params) => {
|
||||
set((state) => {
|
||||
|
|
@ -24,6 +25,12 @@ const useChannelsTableStore = create((set, get) => ({
|
|||
});
|
||||
},
|
||||
|
||||
setAllQueryIds: (allQueryIds) => {
|
||||
set((state) => ({
|
||||
allQueryIds,
|
||||
}));
|
||||
},
|
||||
|
||||
setSelectedChannelIds: (selectedChannelIds) => {
|
||||
set({
|
||||
selectedChannelIds,
|
||||
|
|
|
|||
|
|
@ -2,4 +2,4 @@
|
|||
Dispatcharr version information.
|
||||
"""
|
||||
__version__ = '0.3.3' # Follow semantic versioning (MAJOR.MINOR.PATCH)
|
||||
__build__ = '11' # Auto-incremented on builds
|
||||
__build__ = '14' # Auto-incremented on builds
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue