
function update_count_unread_messages (data) {
    let selected_btn = document.querySelector(".selected")
    if (selected_btn.dataset['ajaxUrl'] !== 'chats'){
        let list_unrd = document.querySelectorAll(".unredmessages_value_text")
        let list_unrd_parent = document.querySelectorAll(".icon_unread_messages")
        let i = 0
        for (i;i < list_unrd.length;i++){
            if (!list_unrd_parent[i].classList.contains("showed")){
                list_unrd_parent[i].classList.toggle("showed")
            }
            list_unrd[i].innerHTML = data.unread_msgs_count.toString()
        }
    }
}

function play_required_beep (data,beep) {
    beep.play()
}


function loader_show_message (data) {
    let loader = document.querySelector(".loader_show_message");
    let send_btn = document.querySelector(".send-message")
    let at = document.querySelector(".attach-file-btn-message")
    if (loader){
        send_btn.classList.add("hide")
        loader.classList.add("show")
        at.classList.add("loader")
    } else {
        console.log("cannot find loader")
    }
}
function loader_hide_message (data) {
    let loader = document.querySelector(".loader_show_message");
    let send_btn = document.querySelector(".send-message")
    let at = document.querySelector(".attach-file-btn-message")
    if (loader){
        send_btn.classList.remove("hide")
        loader.classList.remove("show")
        at.classList.remove("loader")

    } else {
        console.log("cannot find loader")
    }
}