From aaa44685359eb2f1cdd8fa1f249a46964746f1be Mon Sep 17 00:00:00 2001 From: Simon Farshid Date: Fri, 11 Oct 2024 10:08:06 -0700 Subject: [PATCH] fix: notify subscribers if speech or feedback status changes (#973) --- packages/react/src/runtimes/core/BaseThreadRuntimeCore.tsx | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/packages/react/src/runtimes/core/BaseThreadRuntimeCore.tsx b/packages/react/src/runtimes/core/BaseThreadRuntimeCore.tsx index 010cc6e0f..a573addb8 100644 --- a/packages/react/src/runtimes/core/BaseThreadRuntimeCore.tsx +++ b/packages/react/src/runtimes/core/BaseThreadRuntimeCore.tsx @@ -106,7 +106,9 @@ export abstract class BaseThreadRuntimeCore implements ThreadRuntimeCore { const { message } = this.repository.getMessage(messageId); adapter.submit({ message, type }); + this._submittedFeedback[messageId] = { type }; + this.notifySubscribers(); } private _stopSpeaking: Unsubscribe | undefined; @@ -132,6 +134,8 @@ export abstract class BaseThreadRuntimeCore implements ThreadRuntimeCore { }); this.speech = { messageId, status: utterance.status }; + this.notifySubscribers(); + this._stopSpeaking = () => { utterance.cancel(); unsub(); @@ -143,6 +147,7 @@ export abstract class BaseThreadRuntimeCore implements ThreadRuntimeCore { public stopSpeaking() { if (!this._stopSpeaking) throw new Error("No message is being spoken"); this._stopSpeaking(); + this.notifySubscribers(); } public export() {