fixc
This commit is contained in:
@@ -128,8 +128,9 @@ function addMessage({
|
|||||||
/**
|
/**
|
||||||
* Insert a system notice as a root‐level thread item.
|
* Insert a system notice as a root‐level thread item.
|
||||||
* @param {string} content — HTML or plain text for the notice
|
* @param {string} content — HTML or plain text for the notice
|
||||||
|
* @param {boolean} [shouldNotify=true] — whether to trigger a browser notification
|
||||||
*/
|
*/
|
||||||
function addNotice(content) {
|
function addNotice(content, shouldNotify = true) {
|
||||||
const ts = Math.floor(Date.now() / 1000);
|
const ts = Math.floor(Date.now() / 1000);
|
||||||
const id = String(noticeCounter--);
|
const id = String(noticeCounter--);
|
||||||
threads.set(id, {
|
threads.set(id, {
|
||||||
@@ -141,7 +142,7 @@ function addNotice(content) {
|
|||||||
children: [],
|
children: [],
|
||||||
});
|
});
|
||||||
rootIds.push(id);
|
rootIds.push(id);
|
||||||
notifyNotice(content);
|
if (shouldNotify) notifyNotice(content);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -87,6 +87,7 @@ export function initWebSocket(
|
|||||||
addUser(String(id), name);
|
addUser(String(id), name);
|
||||||
addNotice(
|
addNotice(
|
||||||
`<span class="name">${new Option(name).innerHTML}</span> joined.`,
|
`<span class="name">${new Option(name).innerHTML}</span> joined.`,
|
||||||
|
false,
|
||||||
);
|
);
|
||||||
const groups = getGroupedUsers();
|
const groups = getGroupedUsers();
|
||||||
usersListEl.innerHTML = "Online: " + groups.join(", ");
|
usersListEl.innerHTML = "Online: " + groups.join(", ");
|
||||||
@@ -98,6 +99,7 @@ export function initWebSocket(
|
|||||||
const lastName = users.get(sid) || name;
|
const lastName = users.get(sid) || name;
|
||||||
addNotice(
|
addNotice(
|
||||||
`<span class="name">${new Option(lastName).innerHTML}</span> left.`,
|
`<span class="name">${new Option(lastName).innerHTML}</span> left.`,
|
||||||
|
false,
|
||||||
);
|
);
|
||||||
removeUser(sid);
|
removeUser(sid);
|
||||||
const groups = getGroupedUsers();
|
const groups = getGroupedUsers();
|
||||||
@@ -200,7 +202,7 @@ export function initWebSocket(
|
|||||||
};
|
};
|
||||||
|
|
||||||
socket.onclose = () => {
|
socket.onclose = () => {
|
||||||
addNotice("Disconnected.");
|
addNotice("Disconnected.", false);
|
||||||
renderChat(chatEl, inputContainer);
|
renderChat(chatEl, inputContainer);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user