Expand my Community achievements bar.

Guidelines for the Responsible Use of Generative AI in the Experience Cloud Community.

disable chat history

Avatar

Former Community Member

Hi guys,

i have a simple question, that how can i disable chat history. I want that when any one is login, he will not receive even a single history message.

I have already tried "chatmodel.clear()"; but it didn't solve the problem. I m still getting the previous messages after login.

Thanks

Abdul Aziz

8 Replies

Avatar

Former Community Member

hi guys,

I had seen an example some where, in which when ever chat initiates, there is only one message in shows in history. Now i need it but i don't find it... if any one have idea how to do that, please share it.

Thanks

Avatar

Employee

Hi,

there is a property called sessionDependent that could be set for SimpleChat. It would esentially clear chat history after each session.

SimpleChat.sessionDependent

is the key. Let me know if it works.

Thanks
Arun

Avatar

Former Community Member

Hi Arun,

Thanks but i don't use "SimpleChat" in my application.!! Its entirely a custom application in which i use chatmodel not the entire simple chat component!!!

but thanks for your reply.

Abdul Aziz

Avatar

Former Community Member

Hey Hironrmay and Nigel, would u guys please help me in this context.!!??

Thanks in advance :-)

Avatar

Former Community Member

If you are using SimpleChatModel, You can do new SimpleChatModel(true) while creating the model. This will clear the history when the session ends. The Boolean value refers to the sessionDependent parameter. Refer to the source code of SimpleChatModel and SimpleChat for details. Even if you are using 10 swc , you are look at the 9 source of SimpleChatModel.

Thanks

Hironmay Basu

Avatar

Former Community Member

Hi Hironmay,

Thanks for reply,I already create simpleChatModel as new SimpleChatModel(true) but when i close the window and reopen it (even destroy the session by clearing cache manulay) , it will show the history messages.... even in other system too!!! you can check this problem in simpleChatExample too (which is given in example folder of flex skd).

Thanks

Abdul Aziz

Avatar

Employee

Hi Abdul,

I tried the scenario you mentioned. I was able to reproduce the scenario you mentioned.

But try clearing the model before closing your app or before the first person logs into the room. SimpleChatModel.clear() should do the trick. Also dont forget to clear the UI of your chat history.

Also sessiondependent is pretty vague. The sessiondependent items are not cleared until all users leave, and also there is some buffer time the server uses to accomodate users trying to reconnect. So chatHistory is not deleted immediately. I will take a look and figure out why the chat history is present even after all the users leave.

Thanks

Arun

Avatar

Former Community Member

Hi Abdul,

    May be this solves your problem.Just write a creationComplete method in your custom chat component and add the following line

protected function simplechat1_creationCompleteHandler(event:FlexEvent):void

     {

          _model.clear();

     }

Thanks&Regards

Sudhakar Reddy.N