Skip to content

armgit / Cap

Public Imported from GitHub
0

Open source Loom alternative. Beautiful, shareable screen recordings.

Fix export mode detection and frame rendering in Editor

Richie McIlroyfdef3cf5c96f
diff --git a/apps/desktop/src/routes/editor/Editor.tsx b/apps/desktop/src/routes/editor/Editor.tsx
index dd2bba442..4e6d98121 100644
--- a/apps/desktop/src/routes/editor/Editor.tsx
+++ b/apps/desktop/src/routes/editor/Editor.tsx
@@ -90,8 +90,18 @@ export function Editor() {
}
function Inner() {
- const { project, editorState, setEditorState, previewResolutionBase } =
- useEditorContext();
+ const {
+ project,
+ editorState,
+ setEditorState,
+ previewResolutionBase,
+ dialog,
+ } = useEditorContext();
+
+ const isExportMode = () => {
+ const d = dialog();
+ return "type" in d && d.type === "export" && d.open;
+ };
const [layoutRef, setLayoutRef] = createSignal<HTMLDivElement>();
const layoutBounds = createElementBounds(layoutRef);
@@ -183,9 +193,18 @@ function Inner() {
if (editorState.playing) return;
renderFrame(number as number);
},
+ { defer: false },
),
);
+ createEffect(
+ on(isExportMode, (exportMode, prevExportMode) => {
+ if (prevExportMode === true && exportMode === false) {
+ emitRenderFrame(frameNumberToRender());
+ }
+ }),
+ );
+
const updateConfigAndRender = throttle(async (time: number) => {
const config = serializeProjectConfiguration(project);
await commands.updateProjectConfigInMemory(config);
@@ -200,13 +219,6 @@ function Inner() {
),
);
- const { dialog } = useEditorContext();
-
- const isExportMode = () => {
- const d = dialog();
- return "type" in d && d.type === "export" && d.open;
- };
-
return (
<Show when={!isExportMode()} fallback={<ExportPage />}>
<div class="flex flex-col flex-1 min-h-0 animate-in fade-in duration-300">