diff --git a/components/episode-ai-thingy/episode-ai-thingy-generator.tsx b/components/episode-ai-thingy/episode-ai-thingy-generator.tsx index f78baa1..11c8eaf 100644 --- a/components/episode-ai-thingy/episode-ai-thingy-generator.tsx +++ b/components/episode-ai-thingy/episode-ai-thingy-generator.tsx @@ -24,16 +24,15 @@ export function EpisodeAIThingyGenerator({ credits, id }: Props) { const generationButtonText = useMemo(() => { switch (state.status) { - case 'countdown': - return state.timeRemaining === 0 - ? `THERE YOU GO!` - : `Presenting the AI thingy in ${state.timeRemaining} seconds...`; case 'error': return 'Error'; + case 'idle': return 'Do the AI thingy!'; + case 'loading': return 'Doing the AI thingy...'; + case 'success': return 'Done!'; } diff --git a/components/episode-ai-thingy/episode-ai-thingy.tsx b/components/episode-ai-thingy/episode-ai-thingy.tsx index a0c2119..d18c310 100644 --- a/components/episode-ai-thingy/episode-ai-thingy.tsx +++ b/components/episode-ai-thingy/episode-ai-thingy.tsx @@ -55,14 +55,14 @@ export async function EpisodeAIThingy(props: Props) { src={episodeContent.user.avatar_url ?? ''} /> - + Generated by{' '} {episodeContent.user.display_name} ) : ( - - Generated by a generous beecast user + + Generated by a generous beecast user. )} diff --git a/components/episode-ai-thingy/use-episode-content-generator.ts b/components/episode-ai-thingy/use-episode-content-generator.ts index 3bee166..5f79bb0 100644 --- a/components/episode-ai-thingy/use-episode-content-generator.ts +++ b/components/episode-ai-thingy/use-episode-content-generator.ts @@ -3,18 +3,13 @@ import type { Tables } from '@/types/supabase/database'; import { generateEpisodeContent } from '@/lib/services/ai/generate-episode-content'; -import { useEffect, useState } from 'react'; +import { useState } from 'react'; type Params = { id: Tables<'episode'>['id']; }; type State = - | { - data: string; - status: 'countdown'; - timeRemaining: number; - } | { data: string; status: 'success'; @@ -41,40 +36,12 @@ export function useEpisodeContentGenerator({ id }: Params) { setState({ data: episodeContent.text_summary ?? '', - status: 'countdown', - timeRemaining: 3, + status: 'success', }); } catch (error) { setState({ error, status: 'error' }); } }; - useEffect(() => { - switch (state.status) { - case 'countdown': { - const interval = setInterval(() => { - setState((_state) => { - if (_state.status !== 'countdown') { - return _state; - } - - if (_state.timeRemaining <= 0) { - return { ..._state, status: 'success' }; - } - - return { ..._state, timeRemaining: _state.timeRemaining - 1 }; - }); - }, 1000); - - return () => { - clearInterval(interval); - }; - } - - default: - break; - } - }, [state]); - return [state, run] as const; }