Check if chat info has been initialized before starting chat stream

This commit is contained in:
tyler 2024-04-15 14:58:26 -04:00
parent 1736c64b31
commit 9c99f0d3a6

View file

@ -281,6 +281,14 @@ func (c *Client) StartChatStream(handle func(cv ChatView), handleError func(err
return pkgErr("", fmt.Errorf("chat stream already started"))
}
sseEvent := make(chan *sse.Event)
if c.chatInfo == nil {
ci, err := c.getChatInfo()
if err != nil {
return pkgErr("error getting chat info", err)
}
c.chatInfo = ci
}
sseCl := sse.NewClient(c.chatInfo.StreamUrl())
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
sseCl.ReconnectStrategy = backoff.WithContext(