File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -59,6 +59,10 @@ type ChatContextProps = ChatState & {
5959 setDraft : ( message : string ) => void ;
6060 sendTyping : ( params : SendTypingParams ) => void ;
6161 addConversation : ( conversation : Conversation ) => void ;
62+ removeConversation : (
63+ conversationId : ConversationId ,
64+ removeMessages : boolean | undefined
65+ ) => boolean ;
6266 getConversation : ( conversationId : ConversationId ) => Conversation | undefined ;
6367 updateState : ( ) => void ;
6468 setCurrentMessage : ( message : string ) => void ;
@@ -472,6 +476,22 @@ export const ChatProvider = <S extends IChatService>({
472476 [ storage , updateState ]
473477 ) ;
474478
479+ /**
480+ * Remove conversation from collection
481+ * @param conversationId
482+ */
483+ const removeConversation = useCallback (
484+ (
485+ conversationId : ConversationId ,
486+ removeMessages : boolean | undefined = true
487+ ) => {
488+ const result = storage . removeConversation ( conversationId , removeMessages ) ;
489+ updateState ( ) ;
490+ return result ;
491+ } ,
492+ [ storage , updateState ]
493+ ) ;
494+
475495 const resetState = useCallback ( ( ) => {
476496 storage . resetState ( ) ;
477497 updateState ( ) ;
@@ -534,6 +554,7 @@ export const ChatProvider = <S extends IChatService>({
534554 setDraft,
535555 sendTyping,
536556 addConversation,
557+ removeConversation,
537558 getConversation,
538559 setCurrentMessage,
539560 resetState,
You can’t perform that action at this time.
0 commit comments