From a9910cd880a38aa6dc5a5c2b63a61291cdb56e0e Mon Sep 17 00:00:00 2001 From: lonkaars Date: Fri, 25 Jun 2021 10:08:25 +0200 Subject: deletion working better (no more variable referencing) --- pages/editor.tsx | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) (limited to 'pages') diff --git a/pages/editor.tsx b/pages/editor.tsx index 722c4a8..0290fe1 100644 --- a/pages/editor.tsx +++ b/pages/editor.tsx @@ -439,15 +439,10 @@ function TimelineSelection(props: { selectionAreaRef: Ref; }) { useMousetrap(['del', 'backspace'], () => { if (!project.selection.placed) return; - var indexOffset = 0; - project.selection.slides.forEach(slide => { - if (!slideTypes.includes(slide.value.type)) return; - var index = project.timeline.workingTimeline.findIndex(s => s.value?.id == slide.value.id); - if (index == -1) return; - index -= indexOffset; - project.timeline.workingTimeline[index].set(none); - indexOffset++; - }); + var selection = project.selection.slides.attach(Downgraded).value + .map(s => ({ id: s.id.toString(), type: s.type.toString() })) + .filter(s => slideTypes.includes(s.type)); + selection.forEach(slide => project.timeline.workingTimeline.find(s => s.value?.id == slide.id).set(none)); project.update.refreshLiveTimeline.value(); project.selection.merge({ -- cgit v1.2.3