chatscope / use-chat

React hook for state management in chat applications.
https://chatscope.io
MIT License
147 stars 23 forks source link

Initialize/update storage with messages from API response #23

Closed adjiganoff closed 1 year ago

adjiganoff commented 1 year ago

Hi @supersnager

The issue I'm struggling with is pretty basic: storage initialization with message history coming from some external data source. Or as a more advanced example: lazily load earlier messages and update the storage with the response.

I've looked through the IStorage interface and BasicStorage implementation, but didn't find a method (something like addMessages) that would do it. One option I'm considering is to extend BasicStorage with such method and then call the method from the service.

Please, suggest how to do it properly and thanks for the awesome library!

adjiganoff commented 1 year ago

@supersnager sorry for the false alarm, I noticed you answered a similar question in the closed issues https://github.com/chatscope/use-chat/issues/9#issuecomment-1108190552. Seems a custom storage is the way to go.