Skip to content

Commit

Permalink
OV-403: * implement review suggestion
Browse files Browse the repository at this point in the history
  • Loading branch information
Alblupynos committed Sep 26, 2024
1 parent 5350464 commit 6b9d074
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,9 @@ const AudioPlayer: React.FC<Properties> = ({
getAudioData(audioUrl)
.then(({ durationInSeconds }) => {
setDurationInFrames(Math.round(durationInSeconds * FPS));
onSetDuration && onSetDuration(durationInSeconds);
if (onSetDuration) {
onSetDuration(durationInSeconds);
}
})
.catch(() => {
setDurationInFrames(1);
Expand Down
17 changes: 3 additions & 14 deletions frontend/src/bundles/voices/components/voice-card/voice-card.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import { IconName, IconSize } from '~/bundles/common/icons/icons.js';
import { actions as homeActions } from '~/bundles/home/store/home.js';
import { type Voice } from '~/bundles/home/types/types.js';
import { Control } from '~/bundles/studio/components/control/control.js';
import { TEXT_FOR_VOICES } from '~/bundles/voices/constants/constants.js';

type Properties = {
voice: Voice;
Expand All @@ -28,9 +29,6 @@ const VoiceCard: React.FC<Properties> = ({ voice }) => {
const [isLoading, setIsLoading] = useState(false);
const dispatch = useAppDispatch();

const text =
'Hello, I can handle video speech for you, choose me if you like it!';

const { isPlaying: playerIsPlaying, url: playerUrl } = useAppSelector(
({ home }) => home.voicePlayer,
);
Expand All @@ -53,7 +51,7 @@ const VoiceCard: React.FC<Properties> = ({ voice }) => {
void dispatch(
homeActions.generateScriptSpeechPreview({
scriptId: uuidv4(),
text,
text: TEXT_FOR_VOICES,
voiceName: voice.shortName,
}),
)
Expand All @@ -69,16 +67,7 @@ const VoiceCard: React.FC<Properties> = ({ voice }) => {
);
});
},
[
dispatch,
text,
url,
voice,
isPlaying,
setUrl,
setIsLoading,
isLoading,
],
[dispatch, url, voice, isPlaying, setUrl, setIsLoading, isLoading],
);
const handleLikeClick = useCallback((): void => {
dispatch(homeActions.toogleVoiceLike(voice.shortName));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {
SimpleGrid,
Text,
} from '~/bundles/common/components/components.js';
import { EMPTY_VALUE } from '~/bundles/common/constants/constants.js';
import { type Voice } from '~/bundles/home/types/types.js';
import { VoiceCard } from '~/bundles/voices/components/components.js';
import { VoicesSections } from '~/bundles/voices/enums/voices-sections.js';
Expand Down Expand Up @@ -34,7 +35,7 @@ const VoiceSection: React.FC<Properties> = ({ voices, title }) => {
</Badge>
</Flex>

{voices.length > 0 ? (
{voices.length > EMPTY_VALUE ? (
title === VoicesSections.MY_VOICES ? (
<Box className={styles['horizontal']}>
{voices.map((voice) => (
Expand Down
2 changes: 2 additions & 0 deletions frontend/src/bundles/voices/constants/constants.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export { TEXT_FOR_VOICES } from './text-for-voices.constant.js';
export { EMPTY_VALUE } from 'shared';
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
const TEXT_FOR_VOICES =
'Hello, I can handle video speech for you, choose me if you like it!';

export { TEXT_FOR_VOICES };

0 comments on commit 6b9d074

Please sign in to comment.