Git Product home page Git Product logo

Comments (3)

OvidijusParsiunas avatar OvidijusParsiunas commented on August 12, 2024

Hi @MOHD-KAIF-hub.

I am not fully sure why you are attempting to manually toggle the displayLoadingBubble value. The Deep Chat component property values can't be dynamically changed (without the component being completely re-rendered), so when you assign a new value to displayLoadingBubble - the chat will only use the one given at the start. Hence the toggle does not do anything.

If the problem that you are referring to is the fact that the loading bubble is only displaying for a few milliseconds, the reason for that is upon changing the React State via setinitialMessages and setIsLoading - the component will be completely re-rendered. This is a basic React component convention.
To see for yourself you can comment out the code that uses these setters and you will be able to observe the loading bubble working correctly.
To store messages without having the component being re-renderd, I would instead suggest storing it by other means, such as an external variable. E.g. using the following syntax:

const initialMessages: MessageContent[] = [
  {text: 'How are you doing?', role: 'loading'},
  {
    html: `
      <div class="deep-chat-temporary-message">
        <button class="deep-chat-button deep-chat-suggestion-button" style="margin-top: 5px">give some bullet points?</button>
        <button class="deep-chat-button deep-chat-suggestion-button" style="margin-top: 6px">summarize it?</button>
        <button class="deep-chat-button deep-chat-suggestion-button" style="margin-top: 6px">What is this?</button>
      </div>`,
    role: 'user',
  },
];

export const App = () => {
...

And instead of setinitialMessages you can use initialMessages.push().

I would also suggest using the onNewMessage event to track message history, e.g:

onNewMessage={(newMessage) => {
  initialMessages.push(newMessage.message);
}}

Hopefully this helps you. Let me know if you have any questions.
Thanks!

from deep-chat.

MOHD-KAIF-hub avatar MOHD-KAIF-hub commented on August 12, 2024

First of all thanks for your response. I got what the mistake I was doing now I will handle thanks a lot.

from deep-chat.

OvidijusParsiunas avatar OvidijusParsiunas commented on August 12, 2024

Hey, I will be closing this issue since the problem has been resolved. Thanks!

from deep-chat.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.