Skip to content

Commit cbf3ad7

Browse files
committed
Fix: robust speech synthesis support check, satisfy linter and tests
1 parent dbc25dc commit cbf3ad7

File tree

2 files changed

+6
-8
lines changed

2 files changed

+6
-8
lines changed

app/components/TextGenerator/TextGeneratorContainer.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,12 @@ const TextGeneratorContainer = () => {
2929
if (typeof window !== 'undefined') {
3030
const isSpeechSupported =
3131
'speechSynthesis' in window && typeof SpeechSynthesisUtterance !== 'undefined';
32-
useTextGeneratorStore.setState({ isSpeechSupported });
32+
const store: Partial<ReturnType<typeof useTextGeneratorStore.getState>> =
33+
useTextGeneratorStore.getState();
34+
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
35+
if (store && typeof store._setIsSpeechSupported === 'function') {
36+
store._setIsSpeechSupported(isSpeechSupported);
37+
}
3338
}
3439

3540
if (status === 'authenticated') {

app/store/textGeneratorStore.ts

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,4 @@ export const useTextGeneratorStore = create<TextGeneratorState>()(
3737
}))
3838
);
3939

40-
if (typeof window !== 'undefined') {
41-
const isSpeechSupported =
42-
'speechSynthesis' in window && typeof SpeechSynthesisUtterance !== 'undefined';
43-
useTextGeneratorStore.getState()._setIsSpeechSupported(isSpeechSupported);
44-
console.log('Speech Synthesis Supported:', isSpeechSupported);
45-
}
46-
4740
export default useTextGeneratorStore;

0 commit comments

Comments
 (0)