diff --git a/dashboard/src/App.jsx b/dashboard/src/App.jsx index 7bab2e7..6f7dedd 100644 --- a/dashboard/src/App.jsx +++ b/dashboard/src/App.jsx @@ -480,6 +480,7 @@ function App() { } } setBulkSub({ running: false, current: total, total, errors }); + refreshMe(); // Refresh results so each ResultCard picks up its new subtitled video_url. try { const data = await pollJob(jobId); @@ -662,11 +663,13 @@ function App() { if (data.status === 'completed') { setStatus('complete'); clearInterval(interval); + refreshMe(); } else if (data.status === 'failed') { setStatus('error'); const errorMsg = data.error || (data.logs && data.logs.length > 0 ? data.logs[data.logs.length - 1] : "Process failed"); setLogs(prev => [...prev, "Error: " + errorMsg]); clearInterval(interval); + refreshMe(); } else { // Update logs if available if (data.logs) setLogs(data.logs); @@ -677,7 +680,7 @@ function App() { }, 2000); } return () => clearInterval(interval); - }, [status, jobId]); + }, [status, jobId, refreshMe]); // silent: background auto-fetch — never alert(), just log. Managed users need @@ -910,10 +913,13 @@ function App() { if (data.type === 'thumbnail_session') { setProcessingMedia({ type: 'server', payload: `/api/source/${resData.job_id}` }); } + // Minutes are reserved at job start, not at complete. + refreshMe(); } catch (e) { if (e instanceof QuotaError) { setStatus('idle'); + refreshMe(); // Trial users hit the trial minute cap → prompt them to activate the plan // now (unlocks full minutes). Active users → offer a top-up. if (me?.status === 'trialing') { diff --git a/dashboard/src/components/ClipEditor.jsx b/dashboard/src/components/ClipEditor.jsx index af83d64..35a7722 100644 --- a/dashboard/src/components/ClipEditor.jsx +++ b/dashboard/src/components/ClipEditor.jsx @@ -6,6 +6,7 @@ import { } from 'lucide-react'; import { getApiUrl } from '../config'; import { apiFetch, apiJson, QuotaError } from '../lib/api'; +import { useAuth } from '../contexts/AuthContext'; // Full-screen clip editor: shows WHICH source segments a clip was cut from, // lets the user trim/extend/split/reorder them (word-snapped), and re-renders @@ -95,6 +96,7 @@ function editorReducer(state, action) { } export default function ClipEditor({ jobId, clipIndex, clipTitle, onClose, onRerendered }) { + const { refreshMe } = useAuth(); const [edl, setEdl] = useState(null); const [loadError, setLoadError] = useState(null); const [state, dispatch] = useReducer(editorReducer, { segments: [], selected: 0, past: [], future: [], pendingBase: null }); @@ -866,8 +868,10 @@ export default function ClipEditor({ jobId, clipIndex, clipTitle, onClose, onRer dispatch({ type: 'init', segments: data.recipe.segments.map((s) => ({ ...s })) }); setPreviewUrl(`${getApiUrl(data.new_video_url)}?t=${Date.now()}`); onRerendered?.(clipIndex, data); + refreshMe(); } catch (e) { if (e instanceof QuotaError) { + refreshMe(); setRenderError(`not enough minutes left (needs ${e.minutesRequired ?? '?'}, ${e.minutesRemaining ?? 0} remaining)`); } else { setRenderError(e.message || 're-render failed');