@@ -18,99 +18,45 @@ export default function useScheduleTable({
1818 const trackIds = Array . from ( new Set ( events . map ( event => event . track_id ) ) ) ;
1919 const tracks = allTracks . filter ( track => trackIds . includes ( track . id ) ) ;
2020 const slots = allSlots . sort ( sorter ( 'starts_at' ) ) . filter ( slot => eventIds . includes ( slot . event_id ) ) ;
21+ const hallIds = new Set ( slots . map ( slot => slot . hall_id ) ) ;
22+ const halls = allHalls . filter ( hall => hallIds . has ( hall . id ) ) ;
23+
2124 const microslots = Array . from ( new Set ( slots . flatMap ( slot => [
2225 getTime ( slot . starts_at ) ,
2326 getTime ( slot . ends_at ) ,
2427 ] ) ) ) . sort ( ) . map ( ts => toDate ( ts ) ) ;
25- const hallIds = new Set ( slots . map ( slot => slot . hall_id ) ) ;
26- const halls = allHalls . filter ( hall => hallIds . has ( hall . id ) ) ;
27- const skipHallSlots = new Map ( ) ;
2828
2929 const rows = microslots . flatMap ( ( date , slotsIndex , slotsArray ) => {
3030 const isFirst = slotsIndex === 0 ;
3131 const isLast = slotsIndex === slotsArray . length - 1 ;
3232 const nextDate = ! isLast ? slotsArray [ slotsIndex + 1 ] : null ;
3333 const isFirstForTheDay = slotsIndex > 0 && ! isSameDay ( date , slotsArray [ slotsIndex - 1 ] ) ;
3434 const isLastForTheDay = slotsArray ?. [ slotsIndex + 1 ] && ! isSameDay ( date , slotsArray [ slotsIndex + 1 ] ) ;
35- const rowEvents = new Set ( ) ;
36-
37- const eventCells = halls . flatMap ( ( hall , hallIndex , hallsArray ) => {
38- if ( skipHallSlots . has ( hall . id ) ) {
39- const leftToSkip = skipHallSlots . get ( hall . id ) ;
4035
41- if ( leftToSkip <= 1 ) {
42- skipHallSlots . delete ( hall . id ) ;
43- }
44- else {
45- skipHallSlots . set ( hall . id , leftToSkip - 1 ) ;
46- }
47-
48- return [ ] ;
49- }
50-
51- const currentTimeSlots = slots . filter ( slot => compareAsc ( slot . starts_at , date ) === 0 ) ;
52- const currentHallSlot = currentTimeSlots . find ( slot => slot . hall_id === hall . id ) ;
36+ const eventCells = halls . flatMap ( hall => {
37+ const currentHallSlot = slots . find ( slot =>
38+ slot . hall_id === hall . id &&
39+ compareAsc ( slot . starts_at , date ) <= 0 &&
40+ compareAsc ( slot . ends_at , nextDate ) >= 0
41+ ) ;
5342
5443 if ( ! currentHallSlot ) {
5544 return [ {
5645 id : 'blank-' . concat ( hall . id ) ,
5746 } ] ;
5847 }
5948
60- if ( rowEvents . has ( currentHallSlot . event_id ) ) {
61- return [ ] ;
62- }
63-
64- let rowSpan = 1 ;
65-
66- const spanningMicroslots = microslots . filter ( slotDate =>
67- currentHallSlot . starts_at <= slotDate &&
68- currentHallSlot . ends_at >= slotDate
69- ) ;
70-
71- if ( spanningMicroslots . length > 1 ) {
72- rowSpan = spanningMicroslots . length - 1 ;
73-
74- if ( rowSpan > 1 ) {
75- skipHallSlots . set ( hall . id , rowSpan - 1 ) ;
76- }
77- }
78-
79- let colSpan = 1 ;
80-
81- for ( const index of hallsArray . keys ( ) ) {
82- if ( index <= hallIndex ) {
83- continue ;
84- }
85-
86- const currentHall = hallsArray [ index ] ;
87- const currentSlot = currentTimeSlots . find ( slot =>
88- slot . hall_id === currentHall . id &&
89- slot . event_id === currentHallSlot . event_id
90- ) ;
91-
92- if ( ! currentSlot ) {
93- break ;
94- }
95-
96- rowEvents . add ( currentHallSlot . event_id ) ;
97- colSpan ++ ;
98- }
99-
10049 return [ {
10150 id : 'slot-' . concat ( currentHallSlot . id ) ,
10251 attributes : {
10352 className : 'schedule-' . concat ( currentHallSlot . event . language ) . concat ( ' ' ) . concat ( currentHallSlot . event . track ?. css_class ) ,
104- colSpan,
105- rowSpan,
10653 } ,
10754 event : currentHallSlot . event ,
10855 } ] ;
10956 } ) ;
11057
111- const isEmptyRow = false ; // TODO !eventCells.find(slot => !!slot?.event);
11258 const showHeader = isFirst || isFirstForTheDay ;
113- const showSlot = ! isLast && ! isLastForTheDay && ! isEmptyRow ;
59+ const showSlot = ! isLast && ! isLastForTheDay ;
11460
11561 return [
11662 ...showHeader ? [ {
0 commit comments