MCPcopy
hub / github.com/CapSoftware/Cap / ShareButton

Function ShareButton

apps/desktop/src/routes/editor/ShareButton.tsx:23–349  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

21} from "./ui";
22
23function ShareButton() {
24 const { editorInstance, meta, customDomain, editorState, setEditorState } =
25 useEditorContext();
26 const projectPath = editorInstance.path;
27
28 const upload = createMutation(() => ({
29 mutationFn: async () => {
30 setUploadState({ type: "idle" });
31
32 if (!navigator.onLine) {
33 await commands.globalMessageDialog(
34 "You appear to be offline. Please check your internet connection and try again.",
35 );
36 return;
37 }
38
39 console.log("Starting upload process...");
40
41 // Check authentication first
42 const existingAuth = await authStore.get();
43 if (!existingAuth) {
44 throw new Error("You need to sign in to share recordings");
45 }
46
47 const metadata = await commands.getVideoMetadata(projectPath);
48 const plan = await commands.checkUpgradedAndUpdate();
49 const canShare = {
50 allowed: plan || metadata.duration < 300,
51 reason: !plan && metadata.duration >= 300 ? "upgrade_required" : null,
52 };
53
54 if (!canShare.allowed) {
55 if (canShare.reason === "upgrade_required") {
56 await commands.showWindow("Upgrade");
57 throw new Error(
58 "Upgrade required to share recordings longer than 5 minutes",
59 );
60 }
61 }
62
63 const uploadChannel = new Channel<UploadProgress>((progress) => {
64 console.log("Upload progress:", progress);
65 setUploadState(
66 produce((state) => {
67 if (state.type !== "uploading") return;
68
69 state.progress = Math.round(progress.progress * 100);
70 }),
71 );
72 });
73
74 setUploadState({ type: "starting" });
75
76 // Setup progress listener before starting upload
77
78 console.log("Starting actual upload...");
79
80 await exportVideo(

Callers

nothing calls this directly

Calls 6

exportVideoFunction · 0.90
createProgressBarFunction · 0.90
createStoreFunction · 0.85
normalUrlFunction · 0.85
customUrlFunction · 0.85
metaFunction · 0.70

Tested by

no test coverage detected