Skip to content

Add way to load *all* comments when some are hidden due to number of comments #1892

Closed

Description

@pnkfelix

Look at rust-lang/rfcs#2544

Scroll down the the "Load more ..." (below "NNN hidden items" for some NNN).

The link there only loads some of the comments. It would be great to have a way to load all of them (e.g. it would help for people who then use search to find text in the page).

(I did try Alt-click; it did not work for me in this context.)

Activity

  1. fregante commented on Mar 30, 2019

    @fregante
    Member

    This kinda makes sense because if I'm looking for something in those comments, chances are I want to check them all out. However we still need to limit this to, maybe 3 loads at a time, or else on the rare super-long discussion it might load too many pages nobody needs.

  2. pnkfelix commented on Mar 31, 2019

    @pnkfelix
    Author

    Here’s maybe a simpler request: could we add a “load more ...” button that is always in the same (hopefully easily accessible) location, eg right below the description, and just grated out when all are loaded, so that the work flow for loading all comments doesn’t involve repeatedly searching for the link after each load, and instead one can just sit and hit the button in one place until it’s all done?

  3. fregante commented on Apr 1, 2019

    @fregante
    Member

    I don’t think that can integrate nicely with the design.

  4. fregante commented on Jun 6, 2019

    @fregante
    Member

    This can just be added with alt+click, it will probably look a lot like infinite-scroll but instead of using IntersectionObserver it just waits for the click event.

  5. JeanMertz commented on Aug 21, 2019

    @JeanMertz

    Funnily enough, I came searching for this feature request for the exact same reason (searching for a string in Rust RFCs, and not finding them because the comments are collapsed).

    What makes this even more awkward is that searching for that string in the repo itself does return issues containing that string as a result, but then opening that issue, the string can no longer be found, because it is collapsed.

    Personally, I'd like to have a "load all" button, or even better yet "always load all", but I can see how that might be detremental to page loading times (although the current workflow described by @pnkfelix of having to grep for "load more" clicking it, and repeating that several times takes way more time than an initial load all would cost).

  6. warpech commented on Nov 4, 2019

    @warpech

    I would really appreciate this feature. For now, here's a recursive user script that works for me:

    function loadAllComments() {
        let needRescheduling = false;
        const buttons = Array.from(document.querySelectorAll('button'));
        buttons.forEach((button) => {
            if (button.classList.contains('ajax-pagination-btn')) {
                if(!button.hasAttribute('disabled') && button.innerText === 'Load more…') {
                    console.log("found", button);
                    needRescheduling = true;
                    button.dispatchEvent(new MouseEvent('click', {
                        bubbles: true,
                        cancelable: true
                    }));                
                }
                else if(button.hasAttribute('disabled') && button.innerText === 'Loading…') {
                    console.log("waiting", button);
                    needRescheduling = true;
                }
                else {
                    console.log("unrecognized 'Load more' button", button);
                }
            }
        });
        if (needRescheduling) {
            setTimeout(loadAllComments, 200)
        }
        else {
            console.log("all comments loaded");
        }
    }
    
    loadAllComments();

    Here's a version that also expands "Show resolved" comments:

    function loadAllCommentsAndShowResolved() {
      let needRescheduling = false;
      const elems = Array.from(document.querySelectorAll('button, .btn-link.Details-content--closed'));
      elems.forEach((elem) => {
        if (elem.classList.contains('ajax-pagination-btn')) {
          if (!elem.hasAttribute('disabled') && elem.innerText === 'Load more…') {
            console.log("found", elem);
            needRescheduling = true;
            elem.dispatchEvent(new MouseEvent('click', {
              bubbles: true,
              cancelable: true
            }));
          }
          else if (elem.hasAttribute('disabled') && elem.innerText === 'Loading…') {
            console.log("waiting", elem);
            needRescheduling = true;
          }
          else {
            console.log("unrecognized 'Load more' button", elem);
          }
        }
        else if (elem.classList.contains('Details-content--closed') && elem.innerText === 'Show resolved') {
          elem.dispatchEvent(new MouseEvent('click', {
            bubbles: true,
            cancelable: true
          }));
        }
      });
      if (needRescheduling) {
        setTimeout(loadAllCommentsAndShowResolved, 200)
      }
      else {
        console.log("all comments loaded");
      }
    }
    
    loadAllCommentsAndShowResolved();
  7. added 2 commits that reference this issue on Dec 12, 2019
    7a20266
    bcebdef
  8. RentecAaron commented on Feb 18, 2022

    @RentecAaron

    The above recursive script is outdated. Here's a script that will load all hidden comments, including resolved.

    window.addEventListener('load', function () {
      loadComments();
    })
    
    let tryAttempts = 0;
    
    function loadComments () {
    	let needRescheduling = false;
    	const buttons = document.querySelectorAll(".ajax-pagination-btn[data-disable-with]")
    	
    	buttons.forEach((button) => {
    		button.click();
    		needRescheduling = true;
    		tryAttempts = 0;
    	})
    	
    	if (needRescheduling || tryAttempts < 5) {
    		if (needRescheduling) {
    			console.log("Loading comments.")
    		} else {
    			console.log("Looking for more to load.");
    		}
    		tryAttempts++;
    		setTimeout(loadComments, 500)
    	} else {
    		console.log("All comments loaded.");
    
    		const resolvedButtons = document.querySelectorAll(".js-toggle-outdated-comments[data-view-component]");
    
    		resolvedButtons.forEach((button) => {
    			button.click();
    		})
    		
    		console.log("All resolved comments loaded.")
    	}
    }
    
  9. locked as resolved and limited conversation to collaborators on Aug 17, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions