Skip to content
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

Rerun Octo-Linker when blobs are expanded #505

Merged
merged 1 commit into from
Aug 29, 2018

Conversation

leomoty
Copy link
Contributor

@leomoty leomoty commented Aug 28, 2018

This is a possible implementation for #453, we observe the DOM, if any new .blob-expanded nodes are added, then the extension is rerun.

As far as testing goes, I will wait for feedback, I added a single test that clickes the specific .js-expand element and then tries to process a single line from it.

Checklist:

  • If this PR is a new feature, please provide at least one example link
  • Make sure all of the significant new logic is covered by tests

@leomoty leomoty changed the title WIP: Rerun Octo-Linker when blobs are expanded #453 WIP: Rerun Octo-Linker when blobs are expanded Aug 28, 2018
@leomoty
Copy link
Contributor Author

leomoty commented Aug 28, 2018

@stefanbuck I noticed the same e2e breakage on my end, when webpack test takes too long to execute, the page url assert is leaked to the next tests.

@leomoty
Copy link
Contributor Author

leomoty commented Aug 28, 2018

running yarn firefox-open (master branch) with the URL I used for the test:

image

Octolinker is not enabled at all for that page? It works for chrome tho. It seems unrelated to this PR.

Copy link
Member

@stefanbuck stefanbuck left a comment

Choose a reason for hiding this comment

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

Looks almost perfect 😉I would just narrow down the mutation observer and simplify the e2e test a little bit

observer.observe(document.body, {
childList: true,
subtree: true,
});
Copy link
Member

Choose a reason for hiding this comment

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

Not sure if this is really an issue, but I think we should narrow down this observe a little bit to avoid potential side effects / performance issues.

for (const el of document.querySelectorAll('.diff-table tbody')) {
  observerElement(el);
}

I think, by observing diff-table tbody you can also get rid of subtree: true since the mutation happens on that element.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

True, I wanted to get an early review, didn't think about the performance implications

Copy link
Member

Choose a reason for hiding this comment

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

Good idea to get feedback early one 👍


await page.waitForSelector(selector);

await Promise.all([
Copy link
Member

Choose a reason for hiding this comment

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

I think it's enough to check if OctoLinker insert new links into the dom without actually clicking them. Therefore I would suggest to remove everything between line 87-92.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Right, i'll update it.

@stefanbuck
Copy link
Member

Yeah, I noticed that same that e2e tests related to diff view are a bit flaky. I will disable them until I found the root cause.

@stefanbuck
Copy link
Member

Regarding your issue with yarn firefox-open, I have to admit that I don't use this command that often. I can confirm that OctoLinker does not insert any links on the package.json diff, but it works for webpack.config.js. However, it's not related to your PR so feel free to ignore it

@leomoty
Copy link
Contributor Author

leomoty commented Aug 28, 2018

I can't realistically make yarn chrome-open work, it simply fails with:

Manifest file is lacking or unreadable

If you want I can open an issue regarding those.

@stefanbuck
Copy link
Member

Ohhh, haven't seen yarn chrome-open before 😊 Do you think those npm scripts are useful to have? Since I'm working constantly on OctoLinker my default browser is using the dev version by default.

@stefanbuck
Copy link
Member

I think I was able to fix the e2e test issue by using eslint rather than wepack #506.

@leomoty
Copy link
Contributor Author

leomoty commented Aug 28, 2018

@stefanbuck they might lower the barrier a little bit, I cant state the usefulness of chrome-open, since I cant make it to run. Firefox one runs fine. I'll adjust the changes in a bit.

@leomoty leomoty changed the title WIP: Rerun Octo-Linker when blobs are expanded Rerun Octo-Linker when blobs are expanded Aug 28, 2018
@leomoty
Copy link
Contributor Author

leomoty commented Aug 28, 2018

@stefanbuck squashed & force pushed with the changes.

Copy link
Member

@stefanbuck stefanbuck left a comment

Choose a reason for hiding this comment

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

Sorry, I have one last question regarding MutationObserver. I can also have look by myself tomorrow. Apart from that LGTM.

const observer = new MutationObserver(mutations => {
mutations.forEach(mutation => {
const nodes = Array.from(mutation.addedNodes);
if (
Copy link
Member

Choose a reason for hiding this comment

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

Are you sure that this condition is still needed? I think run can be invoked anytime when a mutation is triggered (assume only one mutation is happing when clicking the expand button).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'll confirm, missed that when you talked about restricting the mutation target.

@stefanbuck
Copy link
Member

If you could open an issue for the yarn open-* issue that would be great. I'm not sure how easy it is to get yarn open-chrome working and if we really need those scripts. However something to discuss in that issue. Thank you

@leomoty
Copy link
Contributor Author

leomoty commented Aug 28, 2018

@stefanbuck Updated again, also yes, just running run inside the MutationObserver should be fine, the mutation list always contains something like: text, tr .blob-expanded and repeat.

Copy link
Member

@stefanbuck stefanbuck left a comment

Choose a reason for hiding this comment

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

Works like a charm. Thanks again for addressing this feature request.

@stefanbuck stefanbuck merged commit 9ed3ebc into OctoLinker:master Aug 29, 2018
@stefanbuck
Copy link
Member

Sorry, took me a bit longer than usually to release a new version. However it's on the way and thanks again for adding this cool feature

@leomoty leomoty deleted the issue-453 branch September 5, 2018 20:04
@leomoty
Copy link
Contributor Author

leomoty commented Sep 5, 2018

Hey @stefanbuck, no problem, had some water damage at my house, i'll take a look at #510 this week.

@stefanbuck
Copy link
Member

Oh no what a nightmare. #510 is not that critical so no need to rushing it. Good luck with fix your water issue.

@leomoty
Copy link
Contributor Author

leomoty commented Sep 5, 2018

It is fixed by now, no hardware died.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants