1
Fork 0
mirror of https://github.com/jech/galene.git synced 2024-11-22 08:35:57 +01:00

Fix chathistory and display of anonymous users.

Chathistory messages were formatted incorrectly.
We were also not formatting correctly messages from
anonymous users.
This commit is contained in:
Juliusz Chroboczek 2022-09-06 19:03:50 +02:00
parent 3a2efbcc7e
commit 0fe3ed2e15
2 changed files with 14 additions and 17 deletions

View file

@ -1194,7 +1194,7 @@ func handleAction(c *webClient, a interface{}) error {
for _, m := range h {
err := c.write(clientMessage{
Type: "chathistory",
Id: m.Id,
Source: m.Id,
Username: m.User,
Time: m.Time,
Value: m.Value,

View file

@ -2594,12 +2594,11 @@ function addToChatbox(peerId, dest, nick, time, privileged, history, kind, messa
if(kind !== 'me') {
let p = formatLines(message.toString().split('\n'));
let doHeader = true;
if(!peerId && !dest && !nick) {
doHeader = false;
} else if(lastMessage.nick !== (nick || null) ||
lastMessage.peerId !== peerId ||
if(lastMessage.nick !== (nick || null) ||
lastMessage.peerId !== (peerId || null) ||
lastMessage.dest !== (dest || null) ||
!time || !lastMessage.time) {
console.log("A", nick, peerId, dest, time, lastMessage.time);
doHeader = true;
} else {
let delta = time - lastMessage.time;
@ -2608,16 +2607,14 @@ function addToChatbox(peerId, dest, nick, time, privileged, history, kind, messa
if(doHeader) {
let header = document.createElement('p');
if(peerId || nick || dest) {
let user = document.createElement('span');
let u = serverConnection.users[dest];
let u = dest && serverConnection.users[dest];
let name = (u && u.username);
user.textContent = dest ?
`${nick||'(anon)'} \u2192 ${name || '(anon)'}` :
`${nick || '(anon)'} \u2192 ${name || '(anon)'}` :
(nick || '(anon)');
user.classList.add('message-user');
header.appendChild(user);
}
header.classList.add('message-header');
container.appendChild(header);
if(time) {