mirror of
https://github.com/cpvalente/ontime.git
synced 2026-08-23 16:09:11 +00:00
refactor: small code improvements
This commit is contained in:
committed by
Carlos Valente
parent
e5d2457717
commit
9ab6b30aea
@@ -7,7 +7,6 @@ import {
|
|||||||
MaybeString,
|
MaybeString,
|
||||||
OntimeEntry,
|
OntimeEntry,
|
||||||
OntimeEvent,
|
OntimeEvent,
|
||||||
OntimeGroup,
|
|
||||||
Rundown,
|
Rundown,
|
||||||
SupportedEntry,
|
SupportedEntry,
|
||||||
TimeField,
|
TimeField,
|
||||||
@@ -803,10 +802,8 @@ function optimisticDeleteEntries(entryIds: EntryId[], rundown: Rundown) {
|
|||||||
order = order.filter((id) => id !== entry.id);
|
order = order.filter((id) => id !== entry.id);
|
||||||
} else {
|
} else {
|
||||||
const parent = entries[entry.parent];
|
const parent = entries[entry.parent];
|
||||||
if ('parent' in entries) {
|
if (parent && isOntimeGroup(parent)) {
|
||||||
(parent as OntimeGroup).entries = (parent as OntimeGroup).entries.filter(
|
parent.entries = parent.entries.filter((parentEntry) => parentEntry !== entry.id);
|
||||||
(parentEntry) => parentEntry !== entry.id,
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -160,7 +160,7 @@ export function makeSortableList(order: EntryId[], entries: RundownEntries): Ent
|
|||||||
* Checks whether a drop operation is valid
|
* Checks whether a drop operation is valid
|
||||||
* Currently only used for validating dropping groups
|
* Currently only used for validating dropping groups
|
||||||
*/
|
*/
|
||||||
export function canDrop(targetType?: SupportedEntry & 'end-group', targetParent?: EntryId | null): boolean {
|
export function canDrop(targetType?: SupportedEntry | 'end-group', targetParent?: EntryId | null): boolean {
|
||||||
// this would mean inserting a group inside another
|
// this would mean inserting a group inside another
|
||||||
if (targetType === 'end-group') {
|
if (targetType === 'end-group') {
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
@@ -103,7 +103,11 @@ export const useEventSelection = create<EventSelectionStore>()((set, get) => ({
|
|||||||
clearMultiSelect: () => {
|
clearMultiSelect: () => {
|
||||||
const { selectedEvents } = get();
|
const { selectedEvents } = get();
|
||||||
const [firstSelected] = selectedEvents;
|
const [firstSelected] = selectedEvents;
|
||||||
set({ selectedEvents: new Set(firstSelected || undefined), anchoredIndex: null, entryMode: null });
|
set({
|
||||||
|
selectedEvents: new Set(firstSelected ? [firstSelected] : []),
|
||||||
|
anchoredIndex: null,
|
||||||
|
entryMode: null,
|
||||||
|
});
|
||||||
},
|
},
|
||||||
unselect: (id: string) => {
|
unselect: (id: string) => {
|
||||||
const { entryMode, selectedEvents } = get();
|
const { entryMode, selectedEvents } = get();
|
||||||
|
|||||||
+2
-2
@@ -87,8 +87,8 @@ export default function CuesheetBody({ rowModel, selectedRef, table }: CuesheetB
|
|||||||
let parentBgColour: string | null = null;
|
let parentBgColour: string | null = null;
|
||||||
if (entry.parent) {
|
if (entry.parent) {
|
||||||
const rundown = queryClient.getQueryData<Rundown>(RUNDOWN);
|
const rundown = queryClient.getQueryData<Rundown>(RUNDOWN);
|
||||||
const parentEntry = rundown?.entries[entry.parent];
|
const parentEntry = rundown?.entries[entry.parent] as OntimeGroup | undefined;
|
||||||
parentBgColour = (parentEntry as OntimeGroup).colour ?? null;
|
parentBgColour = parentEntry?.colour ?? null;
|
||||||
}
|
}
|
||||||
return <DelayRow key={key} duration={delayVal} parentBgColour={parentBgColour} />;
|
return <DelayRow key={key} duration={delayVal} parentBgColour={parentBgColour} />;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -771,7 +771,7 @@ export function loadGroupFlagAndEnd(
|
|||||||
currentIndex: MaybeNumber,
|
currentIndex: MaybeNumber,
|
||||||
state = runtimeState,
|
state = runtimeState,
|
||||||
) {
|
) {
|
||||||
if (currentIndex === null) return resetMetaData();
|
if (currentIndex == null) return resetMetaData();
|
||||||
if (state.eventNow === null) return resetMetaData();
|
if (state.eventNow === null) return resetMetaData();
|
||||||
|
|
||||||
const currentGroupId = state.eventNow.parent;
|
const currentGroupId = state.eventNow.parent;
|
||||||
|
|||||||
Reference in New Issue
Block a user