Skip to content
This repository has been archived by the owner on Feb 5, 2025. It is now read-only.

Commit

Permalink
improve voice logic (#483)
Browse files Browse the repository at this point in the history
Co-authored-by: Tyler Han <[email protected]>
  • Loading branch information
2 people authored and sofly committed Jan 7, 2025
1 parent 02cc078 commit dbab517
Show file tree
Hide file tree
Showing 12 changed files with 561 additions and 516 deletions.
9 changes: 6 additions & 3 deletions packages/chat/src/components/NewFooter/BottomLinks/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,10 @@ export const BottomLinks: React.FC<IBottomLinks> = ({
extraLinkText,
showPoweredBy,
}) => {
const showExtraLink = extraLinkText && extraLinkUrl;
const showExtraLink = !!extraLinkText && !!extraLinkUrl;
const showExtraText = !!extraLinkText && !extraLinkUrl;

const showSeparator = showPoweredBy && (showExtraLink || showExtraText);

return (
<div className={clsx(footerLinksContainer({ small: isSmall }), className)}>
Expand All @@ -31,9 +34,9 @@ export const BottomLinks: React.FC<IBottomLinks> = ({
</div>
)}

{showPoweredBy && showExtraLink && <div className={separator} />}
{showSeparator && <div className={separator} />}

{extraLinkText && !extraLinkUrl && <div className={footerNote}>{extraLinkText}</div>}
{showExtraText && <div className={footerNote}>{extraLinkText}</div>}

{showExtraLink && (
<a href={extraLinkUrl} target="_blank" className={extraLinkStyles}>
Expand Down
2 changes: 1 addition & 1 deletion packages/chat/src/views/ChatWidget/ChatWidget.story.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ export const Base = {
allowDangerousHTML: true,
voice: {
url: 'https://runtime-api-review-operator.us-2.development.voiceflow.com',
accessToken: 'VF.DM.67703df8c466f3697baf4df9.OY8scQUFwMJAt3c1',
accessToken: 'test',
},
}}
assistant={{
Expand Down
10 changes: 5 additions & 5 deletions packages/chat/src/views/VoiceWidget/VoiceWidget.view.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import type { VoiceState } from '@/constant/voice.constant';
import { VOICE_STATE } from '@/constant/voice.constant';
import { RuntimeStateAPIContext } from '@/contexts';

import { useVoiceController } from './hooks/use-voice-controller.hook';
import { useVoiceService } from './hooks/use-voice-service.hook';

export const VoiceWidget = () => {
const { assistant, config } = useContext(RuntimeStateAPIContext);
Expand All @@ -15,23 +15,23 @@ export const VoiceWidget = () => {
throw new Error('Voice is not configured in the config');
}

const voiceController = useVoiceController({
const voiceService = useVoiceService({
url: config.voice.url,
userID: config.userID,
assistantID: config.verify.projectID,
accessToken: config.voice.accessToken,
});

useEffect(() => voiceController.onStateUpdate((state) => setState(state)), [voiceController]);
useEffect(() => voiceService.onStateUpdate((state) => setState(state)), [voiceService]);

return (
<VoiceView
state={state}
footer={assistant.common.footerLink}
settings={assistant.voice}
poweredBy={assistant.common.poweredBy}
onEndCall={voiceController.endConversation}
onStartCall={voiceController.startConversation}
onEndCall={voiceService.endConversation}
onStartCall={voiceService.startConversation}
/>
);
};
Loading

0 comments on commit dbab517

Please sign in to comment.