diff --git a/html/realtimechat.js b/html/realtimechat.js
index 7dc984f..946dabf 100644
--- a/html/realtimechat.js
+++ b/html/realtimechat.js
@@ -7,8 +7,10 @@ let objOnlineList = document.getElementById("onlineList");
let lastMessageId = document.getElementById("LMId").innerText;
let reqIsFailed = false;
let firstLoadingWithDisconnectedServer = false;
+let unreadedCount = 0;
const ajaxUrl = document.getElementById("ajaxPath").innerText;
+const originalTitle = document.title;
const audio = new Audio('/newmessage.mp3');
const HTML_SERVER_ONLINE_MARKER = "✅";
const HTML_SERVER_OFFLINE_MARKER = "❌";
@@ -29,6 +31,8 @@ function appendMessage(nick /* if == "***", then system message */, message)
nicknameContainer.innerText = nick;
nicknameContainer.setAttribute("style", "color: #1b4af5");
if (document.hidden) {
+ unreadedCount++;
+ document.title = '(' + unreadedCount + ') ' + originalTitle;
audio.play();
}
}
@@ -111,6 +115,10 @@ function toAJAX()
function loop()
{
+ if (!document.hidden && unreadedCount>0) {
+ unreadedCount = 0;
+ document.title = originalTitle;
+ }
let dots = objPath.innerText;
if (dots === "...") {
dots = ""
diff --git a/ircclient.cpp b/ircclient.cpp
index 95c1233..ad12229 100644
--- a/ircclient.cpp
+++ b/ircclient.cpp
@@ -208,6 +208,8 @@ void IrcClient::toTrigger(const QString& channel, const QString &nickname, const
void IrcClient::toChatLog(QString channel, const QString &nick, const QString &message)
{
channel.remove('#');
+ emit newMessage(m_connectionData.displayName, channel, nick, message);
+
QDir dir(m_connectionData.logFolderPath);
if (not dir.exists(channel)) {
dir.mkdir(channel);
@@ -251,7 +253,6 @@ void IrcClient::toChatLog(QString channel, const QString &nick, const QString &m
QString logMessage {"["+nick+"] " + message + '\n'};
file.write(logMessage.toUtf8());
- emit newMessage(m_connectionData.displayName, channel, nick, message);
file.close();
}