From e8b12d37299f89f5a6d3dc7f670a550ad7592804 Mon Sep 17 00:00:00 2001 From: Juliusz Chroboczek Date: Tue, 24 Dec 2024 01:06:10 +0100 Subject: [PATCH] Fix client-side selective clearChat. We were correctly clearing the chat on the server side, but we were leaving stray entries in the client. Thanks to J.-J. Sarton. --- static/galene.js | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/static/galene.js b/static/galene.js index 4025b87..1a0e60a 100644 --- a/static/galene.js +++ b/static/galene.js @@ -3319,16 +3319,19 @@ function clearChat(id, userId) { } let elts = box.children; - for(let i = 0; i < elts.length; i++) { + let i = 0; + while(i < elts.length) { let row = elts.item(i); - if(!(row instanceof HTMLDivElement)) - continue; - let div = row.firstChild; - console.log(div); - if(!(div instanceof HTMLDivElement)) - continue; - if((!id || div.dataset.id === id) && div.dataset.peerId === userId) - box.removeChild(row); + if(row instanceof HTMLDivElement) { + let div = row.firstChild; + if(div instanceof HTMLDivElement) + if((!id || div.dataset.id === id) && + div.dataset.peerId === userId) { + box.removeChild(row); + continue; + } + } + i++; } }