use-chat icon indicating copy to clipboard operation
use-chat copied to clipboard

Dispatch conversationId expired from ChatService

Open aledeloss opened this issue 1 year ago • 1 comments

Hi, many thanks for the library, it's great! I am having an issue when I need to do other actions rather than adding a message in ChatService. In particular, I would like to have the chance to dispatch other events from the ChatService to the chat, such as a conversation id expired or others. I am storing the conversation id in the backend and validating it on each message. If it expires, I need to create a new one, and readd former messages to the new conversation. This requires that ChatService can somehow inform the chat that that a new conversation id must be requested and then a new conversation created, etc. before actually sending the message to the server. I checked that you set other events, but I am not sure how can I use them and how can I listen to them, am I missing something? Thank you very much in advance!

aledeloss avatar Jul 12 '23 21:07 aledeloss

@aledeloss I think you don't need to tell the chat that something has changed, because storage.updateState does that. When you know in the ChatService that you need to change the message id, just replace the message in the storage and call storage.updateState. The UI will reflect the changes.

supersnager avatar Oct 21 '23 08:10 supersnager