1
Fork 0
mirror of https://github.com/jech/galene.git synced 2024-11-10 02:35:58 +01:00

Implement localMessage.

This commit is contained in:
Juliusz Chroboczek 2021-01-11 19:28:57 +01:00
parent 63e1a6f47d
commit 70e80afd6c

View file

@ -1738,6 +1738,13 @@ function addToChatbox(peerId, dest, nick, time, privileged, kind, message) {
return message;
}
/**
* @param {string} message
*/
function localMessage(message) {
return addToChatbox(null, null, null, Date.now(), false, null, message);
}
function clearChat() {
lastMessage = {};
document.getElementById('box').textContent = '';
@ -1794,7 +1801,7 @@ commands.help = {
let s = '';
for(let i = 0; i < cs.length; i++)
s = s + cs[i] + '\n';
addToChatbox(null, null, null, Date.now(), false, null, s);
localMessage(s);
}
};
@ -1812,7 +1819,7 @@ commands.set = {
let s = "";
for(let key in settings)
s = s + `${key}: ${JSON.stringify(settings[key])}\n`;
addToChatbox(null, null, null, Date.now(), false, null, s);
localMessage(s);
return;
}
let p = parseCommand(r);
@ -2109,17 +2116,14 @@ async function relayTest() {
commands['relay-test'] = {
f: async (c, r) => {
addToChatbox(null, null, null, Date.now(), false, null,
`Relay test in progress...`);
localMessage('Relay test in progress...');
try {
let s = Date.now();
let rtt = await relayTest();
let e = Date.now();
addToChatbox(null, null, null, Date.now(), false, null,
`Relay test successful in ${e-s}ms, RTT ${rtt}ms`);
localMessage(`Relay test successful in ${e-s}ms, RTT ${rtt}ms`);
} catch(e) {
addToChatbox(null, null, null, Date.now(), false, null,
`Relay test failed: ${e}`);
localMessage(`Relay test failed: ${e}`);
}
}
}