11import { useState , useEffect , useMemo } from 'react'
2- import { useDispatch } from 'react-redux'
2+ import { useDispatch , useSelector } from 'react-redux'
33import { setPageTitle } from '/src/actions'
44import { toast } from 'react-toastify'
55
@@ -15,6 +15,11 @@ const Scheduler = ({ draggedAsset }) => {
1515 const [ startTime , setStartTime ] = useState ( getWeekStart ( ) )
1616 const [ events , setEvents ] = useState ( [ ] )
1717 const [ editorData , setEditorData ] = useState ( null )
18+ const currentChannel = useSelector ( ( state ) => state . context . currentChannel )
19+
20+ const channelConfig = useMemo ( ( ) => {
21+ return nebula . getPlayoutChannel ( currentChannel )
22+ } , [ currentChannel ] )
1823
1924 const onResponse = ( response ) => {
2025 const events = response . data . events
@@ -33,7 +38,7 @@ const Scheduler = ({ draggedAsset }) => {
3338 }
3439
3540 const requestParams = {
36- id_channel : 1 ,
41+ id_channel : currentChannel ,
3742 date : DateTime . fromJSDate ( startTime ) . toFormat ( 'yyyy-MM-dd' ) ,
3843 }
3944
@@ -66,7 +71,7 @@ const Scheduler = ({ draggedAsset }) => {
6671 setEditorData ( null )
6772 }
6873
69- for ( const field of nebula . settings . playout_channels [ 0 ] . fields ) {
74+ for ( const field of channelConfig ?. fields || [ ] ) {
7075 const key = field . name
7176 if ( event [ key ] === undefined ) continue
7277 payload . meta [ key ] = event [ key ]
@@ -87,13 +92,13 @@ const Scheduler = ({ draggedAsset }) => {
8792
8893 useEffect ( ( ) => {
8994 loadEvents ( )
90- } , [ startTime ] )
95+ } , [ startTime , currentChannel ] )
9196
9297 useEffect ( ( ) => {
9398 // console.log('Week start time changed', startTime)
9499 const pageTitle = createTitle ( startTime )
95100 dispatch ( setPageTitle ( { title : pageTitle } ) )
96- } , [ startTime ] )
101+ } , [ startTime , currentChannel ] )
97102
98103 //
99104 // Context menu
0 commit comments