- 
          
 - 
                Notifications
    
You must be signed in to change notification settings  - Fork 2.5k
 
show blocked message not parsing > #14151
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
| 
           oof still breaking if no :  | 
    
| 
           can remove the innerText match and use only the innerHtml. thoughts?  | 
    
        
          
                ui/site/src/forum.ts
              
                Outdated
          
        
      | }); | ||
| $('.forum-post__message').each(function (this: HTMLElement) { | ||
| if (this.innerText.match(/(^|\n)>/)) { | ||
| const isVisible = window.getComputedStyle(this).display !== 'none'; | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not a fan of getComputedStyle, it's hacky and slow - and runs on each blog post. Can we test a class instead?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i didn't know this 😮
| 
           Can we instead parse the blockquotes at the moment the message is displayed, when the user clicks the "show blocked message" button?  | 
    
          
 i tried something like this after reverting my prev changes, but now there is some code duplication. i could move it to a separate function but then don't know where to put it.   $('.forum-post__blocked button').on('click', e => {
    const el = (e.target as HTMLElement).parentElement!;
    const message = el.querySelector('.forum-post__message') as HTMLElement;
    if (message.innerHTML.match(/(^|<br>)>/)) {
      const hiddenQuotes = '<span class=hidden-quotes>></span>';
      let result = '';
      let quote = [];
      for (const line of message.innerHTML.split('<br>')) {
        if (line.startsWith('>')) quote.push(hiddenQuotes + line.substring(4).trim());
        else {
          if (quote.length > 0) {
            result += `<blockquote>${quote.join('<br>')}</blockquote>`;
            quote = [];
          }
          result += line + '<br>';
        }
      }
      if (quote.length > 0) result += `<blockquote>${quote.join('<br>')}</blockquote>`;
      message.innerHTML = result;
    }    
    $(el).replaceWith($('.forum-post__message', el));
  }); | 
    
* master: refactor ui/lobby modals fix style of decline challenge page fix typing & usage of lichess.asset.userComplete Update list.txt add 2024 flair hide online status when challenging
#14126
EDIT - https://stackoverflow.com/questions/67286355/div-innertext-loses-new-lines-after-setting-display-to-none is the reason
not sure if this is the proper fix
without blocked button

for some reason idk, when blocked button this happens, so it doesn't get matched by the regex
