Skip to content

armgit / Cap

Public Imported from GitHub
0

Open source Loom alternative. Beautiful, shareable screen recordings.

fix desktop meta

Brendan Alland80c0224f376
diff --git a/apps/desktop/src/routes/editor/Editor.tsx b/apps/desktop/src/routes/editor/Editor.tsx
index af3b9abc7..875f6b8a8 100644
--- a/apps/desktop/src/routes/editor/Editor.tsx
+++ b/apps/desktop/src/routes/editor/Editor.tsx
@@ -14,8 +14,9 @@ import {
onMount,
} from "solid-js";
import { createStore } from "solid-js/store";
-
+import { mergeProps } from "solid-js";
import { makePersisted } from "@solid-primitives/storage";
+
import Cropper, { cropToFloor } from "~/components/Cropper";
import Tooltip from "~/components/Tooltip";
import { events, type Crop } from "~/utils/tauri";
@@ -53,7 +54,14 @@ export function Editor() {
return {
editorInstance,
- meta: () => ctx.metaQuery.data,
+ meta: mergeProps(() => {
+ const d = ctx.metaQuery.data;
+ if (!d)
+ throw new Error(
+ "metaQuery.data is undefined - how did this happen?"
+ );
+ return d;
+ }),
refetchMeta: async () => {
await ctx.metaQuery.refetch();
},
diff --git a/apps/desktop/src/routes/editor/ExportDialog.tsx b/apps/desktop/src/routes/editor/ExportDialog.tsx
index d330a820a..f3da47f7d 100644
--- a/apps/desktop/src/routes/editor/ExportDialog.tsx
+++ b/apps/desktop/src/routes/editor/ExportDialog.tsx
@@ -199,7 +199,7 @@ export function ExportDialog() {
const savePath = await saveDialog({
filters: [{ name: "mp4 filter", extensions: ["mp4"] }],
- defaultPath: `~/Desktop/${meta()?.prettyName}.mp4`,
+ defaultPath: `~/Desktop/${meta?.prettyName}.mp4`,
});
if (!savePath) {
setExportState(reconcile({ type: "idle" }));
@@ -300,7 +300,7 @@ export function ExportDialog() {
setExportState({ type: "uploading", progress: 0 });
// Now proceed with upload
- const result = meta()?.sharing
+ const result = meta?.sharing
? await commands.uploadExportedVideo(projectPath, "Reupload")
: await commands.uploadExportedVideo(projectPath, {
Initial: { pre_created_video: null },
@@ -797,7 +797,7 @@ export function ExportDialog() {
>
<div class="relative">
<a
- href={meta()?.sharing?.link}
+ href={meta.sharing?.link}
target="_blank"
rel="noreferrer"
class="block"
@@ -808,7 +808,7 @@ export function ExportDialog() {
setTimeout(() => {
setCopyPressed(false);
}, 2000);
- navigator.clipboard.writeText(meta()?.sharing?.link!);
+ navigator.clipboard.writeText(meta.sharing?.link!);
}}
variant="lightdark"
class="flex gap-2 justify-center items-center"
diff --git a/apps/desktop/src/routes/editor/ShareButton.tsx b/apps/desktop/src/routes/editor/ShareButton.tsx
index 6c0bb52a8..dd3acb52a 100644
--- a/apps/desktop/src/routes/editor/ShareButton.tsx
+++ b/apps/desktop/src/routes/editor/ShareButton.tsx
@@ -86,7 +86,7 @@ function ShareButton() {
setUploadState({ type: "uploading", progress: 0 });
// Now proceed with upload
- const result = meta()?.sharing
+ const result = meta.sharing
? await commands.uploadExportedVideo(projectPath, "Reupload")
: await commands.uploadExportedVideo(projectPath, {
Initial: { pre_created_video: null },
@@ -136,7 +136,7 @@ function ShareButton() {
return (
<div class="relative">
- <Show when={meta()?.sharing}>
+ <Show when={meta.sharing}>
{(sharing) => {
const url = () => new URL(sharing().link);
diff --git a/apps/desktop/src/routes/editor/context.ts b/apps/desktop/src/routes/editor/context.ts
index 394043294..d9f8bcd4a 100644
--- a/apps/desktop/src/routes/editor/context.ts
+++ b/apps/desktop/src/routes/editor/context.ts
@@ -54,7 +54,7 @@ export type RenderState =
export const [EditorContextProvider, useEditorContext] = createContextProvider(
(props: {
- meta: () => TransformedMeta | undefined;
+ meta: TransformedMeta;
editorInstance: SerializedEditorInstance;
refetchMeta(): Promise<void>;
}) => {
@@ -197,9 +197,7 @@ export const [EditorContextProvider, useEditorContext] = createContextProvider(
return {
...editorInstanceContext,
- get meta() {
- return props.meta;
- },
+ meta: props.meta,
refetchMeta: () => props.refetchMeta(),
editorInstance: props.editorInstance,
dialog,