Create polished demo videos without editing skills. Mac/Windows/Linux
Refresh sharing capacity after cloud recording deletion
webadderall6b5880dc5d15
diff --git a/src/components/video-editor/cloud/CloudShareButton.tsx b/src/components/video-editor/cloud/CloudShareButton.tsxindex 7fe163d9..6c007bc4 100644--- a/src/components/video-editor/cloud/CloudShareButton.tsx+++ b/src/components/video-editor/cloud/CloudShareButton.tsx@@ -1,4 +1,8 @@-import { checkShareCapacity, RECORDING_LIMIT_MESSAGE } from "./shareCapacity";+import {+ checkShareCapacity,+ RECORDING_LIMIT_MESSAGE,+ subscribeShareCapacityChanges,+} from "./shareCapacity";import { SharedRecordings } from "./SharedRecordings";import { saveProjectShareLink } from "./projectShareLinks";import { useI18n } from "@/contexts/I18nContext";@@ -71,19 +75,26 @@ export function CloudShareButton({setCheckingCapacity(false);if (!authToken || !DEFAULT_CLOUD_ENDPOINT) return;let active = true;- setCheckingCapacity(true);- void checkShareCapacity(DEFAULT_CLOUD_ENDPOINT, authToken)- .then((available) => {- if (active) setCapacityAvailable(available);- })- .catch(() => {- if (active) setCapacityAvailable(null);- })- .finally(() => {- if (active) setCheckingCapacity(false);- });+ let generation = 0;+ const refresh = () => {+ const request = ++generation;+ setCheckingCapacity(true);+ void checkShareCapacity(DEFAULT_CLOUD_ENDPOINT, authToken)+ .then((available) => {+ if (active && request === generation) setCapacityAvailable(available);+ })+ .catch(() => {+ if (active && request === generation) setCapacityAvailable(null);+ })+ .finally(() => {+ if (active && request === generation) setCheckingCapacity(false);+ });+ };+ const unsubscribe = subscribeShareCapacityChanges(refresh);+ refresh();return () => {active = false;+ unsubscribe();};}, [authToken]);useEffect(() => {diff --git a/src/components/video-editor/cloud/SharedRecordings.tsx b/src/components/video-editor/cloud/SharedRecordings.tsxindex 778d17cc..e73323b6 100644--- a/src/components/video-editor/cloud/SharedRecordings.tsx+++ b/src/components/video-editor/cloud/SharedRecordings.tsx@@ -1,5 +1,5 @@import { parseSharedRecordingDate } from "./sharedRecordingDate";-import { FREE_RECORDING_LIMIT } from "./shareCapacity";+import { FREE_RECORDING_LIMIT, notifyShareCapacityChanged } from "./shareCapacity";import { LibrarySkeleton } from "../dashboard/LibrarySkeleton";import { ProjectCard } from "../dashboard/ProjectCard";import { DashboardToolbar } from "../dashboard/DashboardToolbar";@@ -83,6 +83,7 @@ export function SharedRecordings({shareCode: code,});if (!result.success) throw new Error(result.error || "Could not delete recording.");+ notifyShareCapacityChanged();setRecordings((current) => current.filter((recording) => recording.code !== code));} catch (cause) {setError(cause instanceof Error ? cause.message : String(cause));diff --git a/src/components/video-editor/cloud/shareCapacity.ts b/src/components/video-editor/cloud/shareCapacity.tsindex 03bfdb4d..34b28798 100644--- a/src/components/video-editor/cloud/shareCapacity.ts+++ b/src/components/video-editor/cloud/shareCapacity.ts@@ -10,3 +10,17 @@ export async function checkShareCapacity(endpoint: string, token: string): Promi// Pending uploads occupy slots too, matching the backend's atomic quota check.return result.videos.length < FREE_RECORDING_LIMIT;}++const capacityListeners = new Set<() => void>();++/** Refresh active quota checks after a successful library mutation in this renderer. */+export function subscribeShareCapacityChanges(listener: () => void): () => void {+ capacityListeners.add(listener);+ return () => {+ capacityListeners.delete(listener);+ };+}++export function notifyShareCapacityChanged(): void {+ for (const listener of capacityListeners) listener();+}diff --git a/tests/ui/publish-cloud.spec.ts b/tests/ui/publish-cloud.spec.tsindex 13686d7d..199a2fea 100644--- a/tests/ui/publish-cloud.spec.ts+++ b/tests/ui/publish-cloud.spec.ts@@ -114,3 +114,28 @@ for (const fails of [false, true]) {).toHaveCount(0);});}++test("deleting from another shared library refreshes a mounted Share quota", async ({ page }) => {+ await page.goto("/tests/ui/shared-recordings.html?capacity");+ await expect(page.getByRole("button", { name: "Share", exact: true })).toBeDisabled();+ await page+ .getByRole("button", { name: "Options for An interrupted upload", exact: true })+ .click();+ page.once("dialog", (dialog) => dialog.dismiss());+ await page.getByRole("menuitem", { name: "Delete recording", exact: true }).click();+ await expect(page.getByRole("button", { name: "Share", exact: true })).toBeDisabled();+ await page+ .getByRole("button", { name: "Options for An interrupted upload", exact: true })+ .click();+ page.once("dialog", (dialog) => dialog.accept());+ await page.getByRole("menuitem", { name: "Delete recording", exact: true }).click();+ await expect(+ page.getByRole("button", { name: "An interrupted upload", exact: true }),+ ).toHaveCount(0);+ await expect(page.getByRole("button", { name: "Share", exact: true })).toBeEnabled();+ await expect(+ page.getByText(+ "You have 5 cloud recordings. Delete one from Shared before sharing another.",+ ),+ ).toHaveCount(0);+});diff --git a/tests/ui/shared-recordings.tsx b/tests/ui/shared-recordings.tsxindex 6b6bb31d..297079ee 100644--- a/tests/ui/shared-recordings.tsx+++ b/tests/ui/shared-recordings.tsx@@ -1,3 +1,5 @@+import { CloudShareButton } from "@/components/video-editor/cloud/CloudShareButton";+import { I18nProvider } from "@/contexts/I18nContext";import { createRoot } from "react-dom/client";import { SharedRecordings } from "@/components/video-editor/cloud/SharedRecordings";import "@/index.css";@@ -21,7 +23,12 @@ let recordings = [url: "https://example.test/s/demo2",},];+if (new URLSearchParams(location.search).has("capacity")) {+ for (let i = 3; i <= 5; i++)+ recordings.push({ ...recordings[0], code: `demo${i}`, title: `Extra recording ${i}` });+}window.electronAPI = {+ onCloudShareProgress: () => () => undefined,openExternalUrl: async (url: string) => {document.getElementById("fixture-result")!.textContent = `Opened ${url}`;return { success: true };@@ -33,13 +40,23 @@ window.electronAPI = {},} as unknown as typeof window.electronAPI;createRoot(document.getElementById("root")!).render(- <main className="dashboard-surface mx-auto mt-3 max-w-6xl rounded-2xl bg-background px-7 pb-10 lg:px-10">- <SharedRecordings- token="fixture"- endpoint="https://example.test/api/upload"- standalone- accountLabel="Demo creator"- />- <p id="fixture-result" role="status" />- </main>,+ <I18nProvider>+ <main className="dashboard-surface mx-auto mt-3 max-w-6xl rounded-2xl bg-background px-7 pb-10 lg:px-10">+ {new URLSearchParams(location.search).has("capacity") && (+ <CloudShareButton+ inline+ projectTitle="Fixture"+ authToken="fixture"+ accountId="fixture-account"+ />+ )}+ <SharedRecordings+ token="fixture"+ endpoint="https://example.test/api/upload"+ standalone+ accountLabel="Demo creator"+ />+ <p id="fixture-result" role="status" />+ </main>+ </I18nProvider>,);