Skip to content

Commit

Permalink
refactor: remove credit spending
Browse files Browse the repository at this point in the history
  • Loading branch information
altaywtf committed Dec 15, 2023
1 parent 7607e5a commit 647e7ec
Showing 1 changed file with 0 additions and 14 deletions.
14 changes: 0 additions & 14 deletions components/episode-ai-thingy/episode-ai-thingy-generator.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,6 @@

import type { Tables } from '@/types/supabase/database';

import {
updateAccountAICredits,
validateAccountAICredits,
} from '@/lib/services/account';
import { transcribeEpisode } from '@/lib/services/ai/transcribe-episode';
import { Box, Button, Callout, Flex, Text } from '@radix-ui/themes';
import { useCallback, useState } from 'react';
Expand Down Expand Up @@ -39,21 +35,11 @@ export function EpisodeAIThingyGenerator({
const [state, setState] = useState<State>({ status: 'idle' });

const generate = useCallback(async () => {
let updatedAiCredits = 0;

try {
const initialAiCredits = await validateAccountAICredits();
updatedAiCredits = await updateAccountAICredits(initialAiCredits - 1);
} catch (error) {
setState({ message: 'Not enough credits.', status: 'error' });
}

try {
setState({ status: 'transcribing' });
const transcription = await transcribeEpisode(id);
setState({ status: 'summarizing', transcription });
} catch (error) {
await updateAccountAICredits(updatedAiCredits + 1);
setState({ message: 'Failed to transcribe episode', status: 'error' });
}
}, [id]);
Expand Down

0 comments on commit 647e7ec

Please sign in to comment.