Skip to content

Commit 9e27352

Browse files
webvs2coderabbitai[bot]wzc520pyfm
authored
flx(sender): modifying 'allowSpeech' changes the response loss in the property (#432)
* flx[Sender]:Modifying 'allowSpeech' changes the response loss in the property * Remove superfluous * Compatibility of input parameter types * Cancel object deconstruction * speechInControlled Judgment of Optimization * Update src/sender/useSpeech.ts Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> * fix: fix computed value --------- Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> Co-authored-by: wzc520pyfm <[email protected]>
1 parent 58d949f commit 9e27352

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

src/sender/useSpeech.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,8 @@ export default function useSpeech(
3232
const onEventSpeech = onSpeech;
3333

3434
// ========================== Speech Config ==========================
35-
const allowSpeechItem =
35+
//All promoted to be reactive
36+
const allowSpeechItem =
3637
computed(() => {
3738
const allowSpeechRaw = toValue(allowSpeech);
3839
if (typeof allowSpeechRaw === 'object') {
@@ -49,10 +50,9 @@ export default function useSpeech(
4950
speechInControlled: false,
5051
}
5152
});
52-
53-
const controlledRecording = computed(() => allowSpeechItem.value.controlledRecording)
54-
const onControlledRecordingChange = allowSpeechItem.value.onControlledRecordingChange
55-
const speechInControlled = allowSpeechItem.value.speechInControlled
53+
const controlledRecording = computed(() => allowSpeechItem.value.controlledRecording);
54+
const onControlledRecordingChange = computed(() => allowSpeechItem.value.onControlledRecordingChange);
55+
const speechInControlled = computed(() => allowSpeechItem.value.speechInControlled);
5656

5757
// ======================== Speech Permission ========================
5858
const permissionState = ref<PermissionState | null>(null);
@@ -127,19 +127,19 @@ export default function useSpeech(
127127

128128
forceBreakRef.value = forceBreak;
129129

130-
if (speechInControlled) {
130+
if (speechInControlled.value) {
131131
// If in controlled mode, do nothing
132-
onControlledRecordingChange?.(!recording.value);
132+
onControlledRecordingChange.value?.(!recording.value);
133133
} else {
134134
ensureRecognition();
135135

136136
if (recognitionRef.value) {
137137
if (recording.value) {
138138
recognitionRef.value.stop();
139-
onControlledRecordingChange?.(false);
139+
onControlledRecordingChange.value?.(false);
140140
} else {
141141
recognitionRef.value.start();
142-
onControlledRecordingChange?.(true);
142+
onControlledRecordingChange.value?.(true);
143143
}
144144
}
145145
}

0 commit comments

Comments
 (0)