real time mode upgrade

master
const an teen 2022-01-01 03:41:34 -05:00
parent 571322c759
commit fc81fa6fb9
2 changed files with 10 additions and 1 deletions

View File

@ -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 = ""

View File

@ -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();
}