Added checks for nil values in chat client StopChatStream function

This commit is contained in:
tyler 2024-01-31 11:23:32 -05:00
parent 20e55ff1d6
commit 787078f720

View file

@ -276,9 +276,18 @@ func (c *Client) StartChatStream(handle func(cv ChatView), handleError func(err
func (c *Client) StopChatStream() {
c.chatStreamMu.Lock()
defer c.chatStreamMu.Unlock()
if c.chatStream == nil {
return
}
// TODO: what order should these be in?
if c.chatStream.sseClient != nil {
c.chatStream.sseClient.Unsubscribe(c.chatStream.sseEvent)
}
if c.chatStream.stop != nil {
c.chatStream.stop()
}
c.chatStream = nil
}