Base solution for your next web application
Open Closed

How to chat with particular user from any page on click? #6799


User avatar
0
mirzanas created

Hi, we want using chat in this way: user can write to another user by clicking on his profile name( or any another link), so first qyestion would be how to open chat modal on custom click from any page? and follow question would be, how to start writing to the particular user on this click?

Angular + Core


7 Answer(s)
  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi @mirzanas

    I assume the clicked link will contain the information of target user. If so, when the link is clicked, you can add the target user as friend (if not added before), and then open the chat bar component.

    You can check the script of chatbar, it has a sample to open chat bar when a new message arrives and user clicks the new message notification on the UI.

  • User Avatar
    0
    mirzanas created

    Now I found how to add friend and open chatbar on click, but still have trouble to open the selected user(new friend) chat on same click, could you help?

  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi @mirzanas

    Sorry for my late response. Are you using Angular or JQuery version ?

  • User Avatar
    0
    mirzanas created

    Angular

  • User Avatar
    0
    ismcagdas created
    Support Team

    If you want to change the selectedUser of chat bar component, you need to make it an Output field and set it externally where you need to.

    Then, the user must be selected on the chat panel automatically.

  • User Avatar
    0
    mirzanas created

    hm.. but I don't directly calling the chat-bar component from my custom component, I am using the 'document', I thought you suggest this in your first answer ''You can check the script of chatbar, it has a sample to open chat bar"

    showChatPanel(): void { document.body.className += ' m-quick-sidebar--on'; document.getElementById('m_quick_sidebar').className += ' m-quick-sidebar--on'; }

  • User Avatar
    0
    ismcagdas created
    Support Team

    @mirzanas

    Yes, this is unfortunately Metronic's way of showing the chat panel. For selecting the user, you can follow my second suggestion. Otherwise, you might need to deal with more staff.