Skip to content

armgit / Cap

Public Imported from GitHub
0

Open source Loom alternative. Beautiful, shareable screen recordings.

Refactor useScreenshotExport to use editorCtx object

Richie McIlroydd137a62812f
diff --git a/apps/desktop/src/routes/screenshot-editor/useScreenshotExport.ts b/apps/desktop/src/routes/screenshot-editor/useScreenshotExport.ts
index 9abc271d2..10e8d754d 100644
--- a/apps/desktop/src/routes/screenshot-editor/useScreenshotExport.ts
+++ b/apps/desktop/src/routes/screenshot-editor/useScreenshotExport.ts
@@ -8,15 +8,8 @@ import { getArrowHeadPoints } from "./arrow";
import { type Annotation, useScreenshotEditorContext } from "./context";
export function useScreenshotExport() {
- const {
- path,
- prettyName,
- latestFrame,
- annotations,
- dialog,
- setDialog,
- project,
- } = useScreenshotEditorContext();
+ const editorCtx = useScreenshotEditorContext();
+ const { latestFrame, annotations, dialog, setDialog, project } = editorCtx;
const [isExporting, setIsExporting] = createSignal(false);
const drawAnnotations = (
@@ -200,9 +193,8 @@ export function useScreenshotExport() {
canvas.height = frame.data.height;
ctx.putImageData(frame.data, 0, 0);
} else {
- // Fallback to loading file
const img = new Image();
- img.src = convertFileSrc(path);
+ img.src = convertFileSrc(editorCtx.path);
await new Promise((resolve, reject) => {
img.onload = resolve;
img.onerror = reject;
@@ -291,7 +283,7 @@ export function useScreenshotExport() {
if (destination === "file") {
const savePath = await save({
filters: [{ name: "PNG Image", extensions: ["png"] }],
- defaultPath: `${prettyName}.png`,
+ defaultPath: `${editorCtx.prettyName}.png`,
});
if (savePath) {
await writeFile(savePath, uint8Array);