Mercurial Hosting > chat
changeset 76:4dfe5af67f91
fix
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Sun, 09 Mar 2025 18:45:39 -0600 |
parents | 377bdda60f0b |
children | 624654817f99 |
files | src/chat.js |
diffstat | 1 files changed, 10 insertions(+), 8 deletions(-) [+] |
line wrap: on
line diff
--- a/src/chat.js Sun Mar 09 18:26:49 2025 -0600 +++ b/src/chat.js Sun Mar 09 18:45:39 2025 -0600 @@ -377,17 +377,19 @@ } function readUpTo(userId,userNameHtml,unread) { - let div = document.querySelector(`div[user="${userId}"]`); - if( div ) { - if( unread == div.getAttribute('unread') ) - return; - div.outerHTML = ''; - } - console.log('readUpTo'); + //console.log(`readUpTo ${unread}`); let divs = document.querySelectorAll('div[post]'); if( unread >= divs.length ) return; - div = divs[divs.length - unread - 1]; + let div = divs[divs.length - unread - 1]; + let old = document.querySelector(`div[unread][user="${userId}"]`); + if( old ) { + //console.log(`was ${div.getAttribute('unread')}`); + if( div == old.parentNode ) + return; + old.outerHTML = ''; + } + //console.log('readUpTo'); let html = `<div user="${userId}" unread="${unread}">read by ${userNameHtml}</div>`; div.insertAdjacentHTML('beforeend',html); }