Repository navigation
Fix show-whitespace on newly sent suggestions - #5106
Conversation
cheap-glitch
left a comment
There was a problem hiding this comment.
Attempt at implementing a listener for new review comments.
| } | ||
|
|
||
| export default function onNewReviewComment(callback: VoidFunction): void { | ||
| delegate(document, '.js-pull-refresh-on-pjax', 'socket:message', callbackWrapper(callback), {capture: true}); |
There was a problem hiding this comment.
This triggers on other events besides new reviews, e.g. when editing or deleting reviews.
In the first case it's actually a good thing I guess, because the contents of the embedded snippets might have been changed and/or added.
There was a problem hiding this comment.
socket:message can't be used I think. The message doesn't always equal DOM change, which sometimes happens later. We had this issue a few years ago when implementing onNewComments, not sure if it applies here.
If it works… it's fine for now.
|
|
||
| function callbackWrapper(callback: VoidFunction): (event: CustomEvent) => void { | ||
| return function (event) { | ||
| if (/^pull request #\d+ updated$/.test(event.detail.data.reason)) { |
There was a problem hiding this comment.
Not sure if the test is really needed, it seems all the messages are the same (with just the id changing).
There was a problem hiding this comment.
The issue is that this event might also be dispatched when a regular comment comes in, so it would effectively duplicate onNewComment as well.
There was a problem hiding this comment.
The issue is that this event might also be dispatched when a regular comment comes in
It is, but not from the same source, so the delegation ignores it.
The issue is that it is dispatched three times when sending a quick review (with "Add single review comment" button), and afaict the three events are virtually indistinguishable
Edit: seems like debouncing does the trick 🤔
There was a problem hiding this comment.
That doesn't sound right. What's happening though is that we have a simple loop with deduplication in init. So even if it's called twice, no duplication happens.
It may be ok, but I'm still wary of this event and I'd probably merge it back into this file so we know it's not safe for general use. A comment like this should also be inlined.
show-whitespace doesn’t work on newly sent suggestionsshow-whitespace on newly sent suggestions
show-whitespace on newly sent suggestionsshow-whitespace on newly sent suggestions
|
Thanks for solving an oldest bug 🔥 |
Fixes #2852
Test URLs
https://togithub.com/refined-github/refined-github/pull/5103/files
Screenshot
capture-1637605310.mp4