Add id to chat messages.
This commit is contained in:
+5
-3
@@ -2958,7 +2958,7 @@ let lastMessage = {};
|
||||
* @param {string} kind
|
||||
* @param {string|HTMLElement} message
|
||||
*/
|
||||
function addToChatbox(peerId, dest, nick, time, privileged, history, kind, message) {
|
||||
function addToChatbox(id, peerId, dest, nick, time, privileged, history, kind, message) {
|
||||
let row = document.createElement('div');
|
||||
row.classList.add('message-row');
|
||||
let container = document.createElement('div');
|
||||
@@ -2973,6 +2973,8 @@ function addToChatbox(peerId, dest, nick, time, privileged, history, kind, messa
|
||||
if(dest)
|
||||
container.classList.add('message-private');
|
||||
|
||||
if(id)
|
||||
container.dataset.id = id;
|
||||
if(peerId) {
|
||||
container.dataset.peerId = peerId;
|
||||
container.dataset.username = nick;
|
||||
@@ -3093,7 +3095,7 @@ function chatMessageMenu(elt) {
|
||||
* @param {string|HTMLElement} message
|
||||
*/
|
||||
function localMessage(message) {
|
||||
return addToChatbox(null, null, null, new Date(), false, false, '', message);
|
||||
return addToChatbox(null, null, null, null, new Date(), false, false, '', message);
|
||||
}
|
||||
|
||||
function clearChat() {
|
||||
@@ -3473,7 +3475,7 @@ commands.msg = {
|
||||
if(!id)
|
||||
throw new Error(`Unknown user ${p[0]}`);
|
||||
serverConnection.chat('', id, p[1]);
|
||||
addToChatbox(serverConnection.id, id, serverConnection.username,
|
||||
addToChatbox(serverConnection.id, null, id, serverConnection.username,
|
||||
new Date(), false, false, '', p[1]);
|
||||
}
|
||||
};
|
||||
|
||||
+2
-2
@@ -212,7 +212,7 @@ function ServerConnection() {
|
||||
/**
|
||||
* onchat is called whenever a new chat message is received.
|
||||
*
|
||||
* @type {(this: ServerConnection, id: string, dest: string, username: string, time: Date, privileged: boolean, history: boolean, kind: string, message: string) => void}
|
||||
* @type {(this: ServerConnection, id: string, source: string, dest: string, username: string, time: Date, privileged: boolean, history: boolean, kind: string, message: string) => void}
|
||||
*/
|
||||
this.onchat = null;
|
||||
/**
|
||||
@@ -497,7 +497,7 @@ ServerConnection.prototype.connect = function(url) {
|
||||
case 'chathistory':
|
||||
if(sc.onchat)
|
||||
sc.onchat.call(
|
||||
sc, m.source, m.dest, m.username, parseTime(m.time),
|
||||
sc, m.id, m.source, m.dest, m.username, parseTime(m.time),
|
||||
m.privileged, m.type === 'chathistory', m.kind,
|
||||
'' + m.value,
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user