sound.onend = () => idPlay = false;
после этого по идее при выводе в консоль должно быть false но нет выводит снова id SELECT * FROM( SELECT
users.login,
user_date.name,
user_date.lastname,
user_date.company_name,
user_date.company_link,
user_date.user_img,
message_in_the_chat.id,
message_in_the_chat.from_user_id,
message_in_the_chat.to_user_id,
message_in_the_chat.message,
message_in_the_chat.read_status,
DATE_FORMAT(message_in_the_chat.write_data, "%d.%m.%Y %H:%i") as msg_data
FROM message_in_the_chat
LEFT JOIN users ON users.id = message_in_the_chat.from_user_id
LEFT JOIN user_date ON users.id = user_date.user_id
WHERE (message_in_the_chat.from_user_id = 1 AND message_in_the_chat.to_user_id =30)
OR (message_in_the_chat.to_user_id = 1 AND message_in_the_chat.from_user_id =30)
ORDER BY `write_data` DESC LIMIT 25 )
ORDER BY `write_data` ASC