Skip to content

Commit

Permalink
standardise tarteelVoiceSearchTrigger
Browse files Browse the repository at this point in the history
  • Loading branch information
faiqali1 committed Aug 3, 2023
1 parent 8e0414f commit b1294d2
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions src/components/TarteelVoiceSearch/Trigger.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,12 @@ interface Props {
onClick: (startFlow: boolean) => void;
}

const isCommandBarAction = (isCommandBar: boolean) => ({
type: isCommandBar
? toggleIsCommandBarVoiceFlowStarted.type
: toggleIsSearchDrawerVoiceFlowStarted.type,
});

const TarteelVoiceSearchTrigger: React.FC<Props> = ({ isCommandBar = false, onClick }) => {
const { t } = useTranslation('common');
const isSupported = useRef(true);
Expand All @@ -40,11 +46,7 @@ const TarteelVoiceSearchTrigger: React.FC<Props> = ({ isCommandBar = false, onCl

const onMicClicked = () => {
onClick(!showCloseIcon);
dispatch({
type: isCommandBar
? toggleIsCommandBarVoiceFlowStarted.type
: toggleIsSearchDrawerVoiceFlowStarted.type,
});
dispatch(isCommandBarAction(isCommandBar));
};

// check whether the microphone is supported first.
Expand Down

0 comments on commit b1294d2

Please sign in to comment.