-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Fix conflict-marker
duplicated
#6839
Conversation
This unfortunately triggers 25 HTTP requests every time you open the pull requests page, which isn't acceptable. We need to use |
Ok I'll make bunch API call as it was before |
source/features/conflict-marker.tsx
Outdated
@@ -72,25 +51,22 @@ async function init(): Promise<false | void> { | |||
} | |||
} | |||
|
|||
function init(signal: AbortSignal): void { | |||
observe('#js-issues-toolbar', addConflictMarkers, {signal}); |
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.
What is this element? Does it exist on the milestones page? Does it work there now?
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.
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 think this will fail on slower connections because the observer will call the callback as soon as #js-issues-toolbar
is found, but at that point the long list of PRs might not be done downloading yet. This is why I was suggesting to use batched-function and the link selector
const addIcon = batchedFunction((icons) => {
// create query, etc
});
observe('.js-issue-row:has(.octicon-git-pull-request.color-fg-open) a.js-navigation-open', addIcon, {signal})
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've tested a lot but It can detect icons successly. But I'll test more slow network conditions.
And is your suggestion works correctly? As I know, the selector-observe only works as single element, not all elements.
Edit: I think there is some other api; batchedFunction. I'll check this later
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.
As I know, the selector-observe only works as single element, not all elements
No, the observer detects any and all elements that appear on the page until the next page load.
Here's what happens with the suggested code:
observe
finds 3 elements- calls
addIcon
once per element - batched function then calls the anonymous function with a single array:
[prLink1, prLink2, prLink3]
- you can use this array to construct the GQL call
- if more items are detected later, it repeats from step 1
On fast connections maybe batchedFunction will call the function with 25 items, on slower connections it'll make multiple API calls, that's ok. The difference is that no element risks being forgotten + it always happens as soon as possible, regardless of your connection.
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.
Exactly, that was I thought.
I'm just wondering is there existing some utility function: batchedFunction, and the batchedFunction's throttle (or debounce) time.
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.
What do you mean? It does exist and we're already using it. We don't need to change it at this point https://github.com/Richienb/batched-function
Nice, that looks pretty simple to implement in more features |
Test URLs | ||
https://github.com/pulls | ||
https://github.com/refined-github/sandbox/issues?q=conflict | ||
https://github.com/kubernetes/kubernetes/milestone/62 |
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.
This section exists to simplify testing so we should try to use URLs that do and always will include the feature. Our sandbox repo is where these scenarios exist and can be created.
); | ||
} | ||
} | ||
} | ||
|
||
function init(signal: AbortSignal): void { | ||
observe('.js-issue-row:has(.octicon-git-pull-request.color-fg-open) a.js-navigation-open', batchedFunction(addIcon, {delay: 100}), {signal}); |
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.
Description
conflict-marker
duplicated #6809Test URLs
Screenshot