Skip to content

armgit / Cap

Public Imported from GitHub
0

Open source Loom alternative. Beautiful, shareable screen recordings.

Create Shareable Link button

Brendan Allan7380582820ec
diff --git a/apps/desktop-solid/src/routes/editor/Editor.tsx b/apps/desktop-solid/src/routes/editor/Editor.tsx
index 56f297162..98a239764 100644
--- a/apps/desktop-solid/src/routes/editor/Editor.tsx
+++ b/apps/desktop-solid/src/routes/editor/Editor.tsx
@@ -418,6 +418,7 @@ import {
ASPECT_RATIOS,
DEFAULT_GRADIENT_FROM,
DEFAULT_GRADIENT_TO,
+ DEFAULT_PROJECT_CONFIG,
} from "./projectConfig";
import { createMutation } from "@tanstack/solid-query";
@@ -524,13 +525,33 @@ function ExportButton() {
}
function ShareButton() {
- const { videoId } = useEditorContext();
- const [meta] = createResource(() => commands.getRecordingMeta(videoId));
+ const { videoId, presets } = useEditorContext();
+ const [meta, metaActions] = createResource(() =>
+ commands.getRecordingMeta(videoId)
+ );
+
+ const uploadVideo = createMutation(() => ({
+ mutationFn: async () => {
+ const res = await commands.uploadRenderedVideo(
+ videoId,
+ presets.getDefaultConfig() ?? DEFAULT_PROJECT_CONFIG
+ );
+ if (res.status !== "ok") throw new Error(res.error);
+ },
+ onSuccess: () => metaActions.refetch(),
+ }));
return (
<Show
when={meta()?.sharing}
- fallback={<Button disabled>Create shareable link</Button>}
+ fallback={
+ <Button
+ disabled={uploadVideo.isPending}
+ onClick={() => uploadVideo.mutate()}
+ >
+ Create Shareable Link
+ </Button>
+ }
>
{(sharing) => {
const url = () => new URL(sharing().link);
diff --git a/apps/desktop-solid/src/routes/prev-recordings.tsx b/apps/desktop-solid/src/routes/prev-recordings.tsx
index 2136d07b9..c4cec8cb6 100644
--- a/apps/desktop-solid/src/routes/prev-recordings.tsx
+++ b/apps/desktop-solid/src/routes/prev-recordings.tsx
@@ -114,7 +114,6 @@ export default function () {
const uploadVideo = createMutation(() => ({
mutationFn: async () => {
- console.log("bruh");
const res = await commands.uploadRenderedVideo(
videoId,
presets.getDefaultConfig() ?? DEFAULT_PROJECT_CONFIG