1
Fork 0
mirror of https://github.com/jech/galene.git synced 2024-11-23 00:55: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; return message;
} }
/**
* @param {string} message
*/
function localMessage(message) {
return addToChatbox(null, null, null, Date.now(), false, null, message);
}
function clearChat() { function clearChat() {
lastMessage = {}; lastMessage = {};
document.getElementById('box').textContent = ''; document.getElementById('box').textContent = '';
@ -1794,7 +1801,7 @@ commands.help = {
let s = ''; let s = '';
for(let i = 0; i < cs.length; i++) for(let i = 0; i < cs.length; i++)
s = s + cs[i] + '\n'; s = s + cs[i] + '\n';
addToChatbox(null, null, null, Date.now(), false, null, s); localMessage(s);
} }
}; };
@ -1812,7 +1819,7 @@ commands.set = {
let s = ""; let s = "";
for(let key in settings) for(let key in settings)
s = s + `${key}: ${JSON.stringify(settings[key])}\n`; s = s + `${key}: ${JSON.stringify(settings[key])}\n`;
addToChatbox(null, null, null, Date.now(), false, null, s); localMessage(s);
return; return;
} }
let p = parseCommand(r); let p = parseCommand(r);
@ -2109,17 +2116,14 @@ async function relayTest() {
commands['relay-test'] = { commands['relay-test'] = {
f: async (c, r) => { f: async (c, r) => {
addToChatbox(null, null, null, Date.now(), false, null, localMessage('Relay test in progress...');
`Relay test in progress...`);
try { try {
let s = Date.now(); let s = Date.now();
let rtt = await relayTest(); let rtt = await relayTest();
let e = Date.now(); let e = Date.now();
addToChatbox(null, null, null, Date.now(), false, null, localMessage(`Relay test successful in ${e-s}ms, RTT ${rtt}ms`);
`Relay test successful in ${e-s}ms, RTT ${rtt}ms`);
} catch(e) { } catch(e) {
addToChatbox(null, null, null, Date.now(), false, null, localMessage(`Relay test failed: ${e}`);
`Relay test failed: ${e}`);
} }
} }
} }