Merge branch 'master' into wip/migratedb

This commit is contained in:
cv
2021-05-28 14:46:54 +02:00
27 changed files with 284 additions and 110 deletions
@@ -18,11 +18,12 @@
/* 2/3 window, hide previews */
@media (max-width: 1250px) and (min-height: 700px) {
.mainContainer {
height: 100%;
grid-template-rows: 1fr 1fr;
grid-template-columns: 48em 1fr 1fr;
grid-template-areas:
/* grid-template-areas:
'even play sett'
'even mess sett';
'even mess sett'; */
}
.info {
@@ -40,6 +41,11 @@
'play';
}
.messages,
.playback {
min-width: 31em;
}
.editor,
.info,
.settings {
@@ -17,7 +17,7 @@ export default function ActionButtons(props) {
aria-label='Options'
size='xs'
icon={<FiZap />}
_expanded={{ bg: 'pink.300', color: 'white' }}
_expanded={{ bg: 'orange.300', color: 'white' }}
_focus={{ boxShadow: 'none' }}
backgroundColor={'orange.200'}
color={'orange.500'}
@@ -14,7 +14,8 @@ import { SelectCollapse, HandleCollapse } from 'app/context/collapseAtom';
import { useAtom } from 'jotai';
const ExpandedBlock = (props) => {
const { provided, data, next, delay, delayValue, actionHandler } = props;
const { provided, data, eventIndex, next, delay, delayValue, actionHandler } =
props;
const oscid = data.id.length > 4 ? '...' : data.id;
@@ -80,7 +81,9 @@ const ExpandedBlock = (props) => {
actionHandler('update', { field: 'note', value: v })
}
/>
<span className={style.oscLabel}>{`OSC ID: ${oscid}`}</span>
<span className={style.oscLabel}>
{`/ontime/goto ${eventIndex + 1} << OSC >> /ontime/gotoid ${oscid}`}
</span>
</div>
<Icon
className={style.more}
@@ -156,7 +159,7 @@ const CollapsedBlock = (props) => {
};
export default function EventBlock(props) {
const { data, selected, delay, index, actionHandler } = props;
const { data, selected, delay, index, eventIndex, actionHandler } = props;
// const [collapsed, setCollapsed] = useState(checkLocalStorage(data.id));
@@ -200,6 +203,7 @@ export default function EventBlock(props) {
) : (
<ExpandedBlock
provided={provided}
eventIndex={eventIndex}
data={data}
next={props.next}
delay={delay}
+26 -13
View File
@@ -27,7 +27,7 @@ export default function EventList(props) {
},
'Alt+ArrowUp': () => {
if (cursor == null) setCursor(0);
else if (cursor >= 0) setCursor(cursor - 1);
else if (cursor > 0) setCursor(cursor - 1);
},
'Alt+KeyE': (event) => {
event.preventDefault();
@@ -49,7 +49,7 @@ export default function EventList(props) {
return () => {
unsubscribe();
};
}, [cursor, events.length, eventsHandler]);
}, [cursor, events, eventsHandler]);
// handle incoming messages
useEffect(() => {
@@ -62,7 +62,6 @@ export default function EventList(props) {
// Handle playstate
socket.on('selected', (data) => {
setSelected(data);
console.log('debug cursor setted', data);
});
socket.on('next-id', (data) => {
setNext(data);
@@ -80,13 +79,20 @@ export default function EventList(props) {
if (cursorSettings !== 'locked' || selected == null) return;
if (selected.index == null) return;
setCursor(selected.index);
}, [selected, cursorSettings]);
let eventIndex = -1;
let gotoIndex = -1;
for (const e of events) {
gotoIndex++;
if (e.type === 'event') eventIndex++;
if (eventIndex === selected.index) break;
}
setCursor(gotoIndex);
}, [events, selected, cursorSettings]);
// attach scroll to cursor
useEffect(() => {
if (cursor == null || cursorRef.current == null) return;
console.log('debug cursor scrolling');
cursorRef.current.scrollIntoView({
behavior: 'smooth',
@@ -117,8 +123,7 @@ export default function EventList(props) {
console.log('EventList: events in event list', events);
let cumulativeDelay = 0;
console.log('debug selected', selected);
let eventIndex = -1;
return (
<div className={style.eventContainer}>
@@ -131,20 +136,28 @@ export default function EventList(props) {
ref={provided.innerRef}
>
{events.map((e, index) => {
let isCursor = cursor === index;
if (index === 0) cumulativeDelay = 0;
if (index === 0) {
cumulativeDelay = 0;
eventIndex = -1;
}
if (e.type === 'delay' && e.duration != null) {
cumulativeDelay += e.duration;
} else if (e.type === 'block') cumulativeDelay = 0;
} else if (e.type === 'block') {
cumulativeDelay = 0;
} else if (e.type === 'event') {
eventIndex++;
}
return (
<div
ref={isCursor ? cursorRef : undefined}
ref={cursor === index ? cursorRef : undefined}
key={e.id}
className={isCursor ? style.cursor : undefined}
className={cursor === index ? style.cursor : undefined}
>
<EventListItem
type={e.type}
index={index}
eventIndex={eventIndex}
data={e}
selected={selected?.id === e.id}
next={next === e.id}
@@ -18,6 +18,7 @@ const EventListItem = (props) => {
const {
type,
index,
eventIndex,
data,
selected,
next,
@@ -71,6 +72,7 @@ const EventListItem = (props) => {
return (
<EventBlock
index={index}
eventIndex={eventIndex}
data={data}
selected={selected}
next={next}