Skip to content

Conversation

@notlmn
Copy link
Contributor

@notlmn notlmn commented May 28, 2019

Closes #1729.
Implements and closes #825.

The feature now allows collapsing/expanding:

@fregante
Copy link
Member

fregante commented May 30, 2019

  1. In Firefox, clicking any "Show comment" in Move loading logic into each feature #1694 freezes the browser for 4 seconds in my case, but not in Chrome. Can you look into it?

  2. Also review comments don't work in Chrome and Firefox, here https://github.com/sindresorhus/refined-github/pull/1896/files

  3. The suggested link for large diffs only has one large diff on the page: https://github.com/parcel-bundler/parcel/pull/2967/files

@notlmn
Copy link
Contributor Author

notlmn commented Jun 2, 2019

3. The suggested link for large diffs only has one large diff on the page: parcel-bundler/parcel/pull/2967/files

There are multiple of them on that page. It is the same as loading diffs for deleted files: https://github.com/sindresorhus/refined-github/pull/1524/files.

image


  1. In Firefox, clicking any "Show comment" in Move loading logic into each feature #1694 freezes the browser for 4 seconds in my case, but not in Chrome. Can you look into it?

Happens to me on Chrome too. Not a bug, just main thread jank for clicking on 90 elements all at once. (Any solution?)


2. Also review comments don't work in Chrome and Firefox, here sindresorhus/refined-github/pull/1896/files

Missed that, added it in.

@fregante
Copy link
Member

fregante commented Jun 2, 2019

Happens to me on Chrome too. Not a bug, just main thread jank for clicking on 90 elements all at once. (Any solution?)

It's worth investigating if it's the click or the selection being slow

@notlmn
Copy link
Contributor Author

notlmn commented Jun 2, 2019

It's the clicks, events being triggered recursively. But the functions early return anyway.

image

@fregante
Copy link
Member

fregante commented Jun 4, 2019

Should we space them out / delay them a bit? We can't cause multi-second freezes.

In this case I'd probably click no more than 3 per second, also because it's gonna take longer than that to open + see them anyway, but only the "Load diff". You can probably implement this by using await delay(300) in the loop: https://www.npmjs.com/package/delay

Additionally, perhaps, it could be limited to 10 files at a time, but this code might be a bit ugly and maybe not worth it.

@fregante
Copy link
Member

fregante commented Jun 6, 2019

Also can you rename this to toggle-everything-with-alt?

@fregante fregante changed the title Restore toggle-all-things-with-alt feature Restore toggle-everything-with-alt feature Jun 22, 2019
@fregante
Copy link
Member

Can you add the same mechanism here? https://github.com/sindresorhus/refined-github/pull/2073/files#diff-bfeb5de166cf585c43d9150166877a54R89

Except spaced every 3 and using requestAnimationFrame instead

@notlmn
Copy link
Contributor Author

notlmn commented Jul 10, 2019

Can you add the same mechanism here? sindresorhus/refined-github/pull/2073/files#diff-bfeb5de166cf585c43d9150166877a54R89

The handlers are delegated over to .repository-content, so this works even for ajaxed file diffs in a PR even without using that util.


Except spaced every 3 and using requestAnimationFrame instead

I don't seem to follow you on this.

If you are talking about #2087 (comment), then that's not possible, as the possible solution in #2073 mentioned would not work here. Spacing out callback to let the user scroll will cause the last scroll position to be invalidated and when the callback is eventually fired in rAF, the page scrolls to random positions for each callback.

Having a jank is pretty reasonable IMHO (instead of handling scroll position changes for random file load jumps).

@fregante
Copy link
Member

fregante commented Jul 11, 2019

There might have been some miscommunication. My comment only was referring to the await promise setTimeout mechanism (652bb9e#diff-bfeb5de166cf585c43d9150166877a54R90) but the link I had posted pointed to the wrong line (probably after a commit changed its line)

@notlmn notlmn requested review from busches and sindresorhus July 31, 2019 11:36
@notlmn notlmn mentioned this pull request Jul 31, 2019
@fregante
Copy link
Member

I'm sorry, I think this feature can no longer be made of just 2 functions. In its first iteration last year, all toggles behaved similarly, now it seems that each one needs to behave differently because we keep fixing one side and breaking the other.

Example in Chrome (you can see the menus flashing):

In Firefox it's way worse as it takes longer and the scroll goes nuts.


How about this: let's focus on one feature and get that one in first, for example #825

Ensure that it works in both browsers and without long stalls, we'll merge it.

@fregante
Copy link
Member

fregante commented Aug 11, 2019

You can leave the name as toggle-everything-with-alt at the moment. Probably you can't use any scroll anchoring because the loads are asynchronous.

@fregante
Copy link
Member

fregante commented Aug 12, 2019

I have good news for this:

Toggle can be simulated via:

document.dispatchEvent(new KeyboardEvent('keydown', {code: 'KeyI', key: 'i'}))

The i key will toggle all File comments, it's a native GitHub shortcut. Hopefully this can be integrated easily (in the next PR). Goes to show how each part has its own way to do things.

@fregante
Copy link
Member

Ping on this if you have time

@notlmn
Copy link
Contributor Author

notlmn commented Sep 2, 2019

Ping on this if you have time

Sorry I couldn't reply on this, I've been away from keyboard lately because of a lot of distractions. I'll try to get back to handling things as fast as I can.

@notlmn
Copy link
Contributor Author

notlmn commented Sep 2, 2019

I thought of closing this PR and opening a new one as it was getting a bit complex with way too many reviews, but I think I found solutions to the above issues, so left it as is.


Example in Chrome (you can see the menus flashing):
...
In Firefox it's way worse as it takes longer and the scroll goes nuts.

Found the source of that bug, I was targeting the summary element deep within the hidden comment, which is also that dropdown.


I have good news for this:
...
Toggle can be simulated via:
...
The i key will toggle all File comments, it's a native GitHub shortcut. Hopefully this can be integrated easily (in the next PR). Goes to show how each part has its own way to do things.

That still has the issues mentioned above in #2087 (comment), the focus keeps shifting to the last file in the list, adding/removing is still the better way to go.

@fregante
Copy link
Member

fregante commented Sep 2, 2019

Tested in Firefox.

This still freezes the browser for 1s+ to toggle all of those... but that's passable.

Seems to work correctly.

Does not work. The menu stays open as if the click was not registered at all. Previously reported in #2087 (comment)

Seems to work correctly.

@fregante fregante self-assigned this Sep 2, 2019
@fregante
Copy link
Member

fregante commented Sep 2, 2019

As said before, I was no a fan of all the if in those two functions, they handled too much.

I rewrote the feature trying to split it where it made sense and it's a bit shorter and readable.

However I dropped the part that wasn't working (as per my previous comment) and given how complex it was, I'd rather see it replaced by something like

anchorScroll(() => {
    document.dispatchEvent(new KeyboardEvent('keydown', {code: 'KeyI', key: 'i'}))
}, clickedElement.closest('.js-file'));

But that can come in a secondary PR. I'll test this further in both browser and I'll merge it soon.

Copy link
Member

@fregante fregante left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's time

Thank you for the patience! This PR was open for a while :D

@fregante fregante removed their assignment Sep 2, 2019
@fregante fregante merged commit 035d841 into refined-github:master Sep 2, 2019
@notlmn notlmn deleted the restore-toggle-all-things branch September 3, 2019 02:29
@fregante fregante mentioned this pull request Dec 18, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Development

Successfully merging this pull request may close these issues.

Restore toggle-all-things-with-alt feature Add support for loading all large diffs at once

2 participants