Skip to content

armgit / Cap

Public Imported from GitHub
0

Open source Loom alternative. Beautiful, shareable screen recordings.

chore: revalidate path on transcription generation (#993)

Ameer Al Ashhab09110a0f2cfc
diff --git a/apps/web/actions/videos/get-status.ts b/apps/web/actions/videos/get-status.ts
index d0da04c7d..1a1210a74 100644
--- a/apps/web/actions/videos/get-status.ts
+++ b/apps/web/actions/videos/get-status.ts
@@ -7,6 +7,7 @@ import { provideOptionalAuth, VideosPolicy } from "@cap/web-backend";
import { Policy, type Video } from "@cap/web-domain";
import { eq } from "drizzle-orm";
import { Effect, Exit } from "effect";
+import { revalidatePath } from "next/cache";
import * as EffectRuntime from "@/lib/server";
import { isAiGenerationEnabled } from "@/utils/flags";
import { transcribeVideo } from "../../lib/transcribe";
@@ -178,6 +179,8 @@ export async function getVideoStatus(
console.log(
`[Get Status] AI metadata generation completed for video ${videoId}`,
);
+ // Revalidate the share page to reflect new AI data
+ revalidatePath(`/s/${videoId}`);
} catch (error) {
console.error(
`[Get Status] Error generating AI metadata for video ${videoId}:`,
diff --git a/apps/web/app/s/[videoId]/Share.tsx b/apps/web/app/s/[videoId]/Share.tsx
index c7d9d9349..e0a331696 100644
--- a/apps/web/app/s/[videoId]/Share.tsx
+++ b/apps/web/app/s/[videoId]/Share.tsx
@@ -133,8 +133,6 @@ const useVideoStatus = (
return shouldContinuePolling() ? 2000 : false;
},
refetchIntervalInBackground: true,
- refetchOnWindowFocus: true,
- refetchOnMount: "always",
staleTime: 1000,
});
};
@@ -194,9 +192,16 @@ export const Share = ({
}
if (transcriptionStatus === "COMPLETE") {
- // Only show loading for AI if enabled and currently processing
- if (aiGenerationEnabled && aiData.processing === true) {
- return true;
+ if (aiGenerationEnabled) {
+ const noAiData = !(
+ aiData.title ||
+ aiData.summary ||
+ (aiData.chapters && aiData.chapters.length > 0)
+ );
+ // Show loading if AI is processing OR if no AI data exists yet
+ if (aiData.processing === true || noAiData) {
+ return true;
+ }
}
}