-
Notifications
You must be signed in to change notification settings - Fork 50
feat: add a preview of the incriminated code during mouse over #52
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
Conversation
|
Seems better now ^^ |
|
I guess the best is to cache the innerText and not the whole code (to avoid consuming more memory than required). async function fetchCodeLine(event, url, location, cache) {
const [target] = event.srcElement.getElementsByClassName('tooltip');
if (cache.has(url)) {
target.innerText = cache.get(url);
return;
}
target.innerText = "Loading ...";
const code = await fetch(url).then((response) => response.text());
target.innerText = code.length ? getLineFromFile(code, location) : "Line not found ...";
cache.set(url, target.innerText);
} |
public/js/popup.js
Outdated
| const [target] = event.srcElement.getElementsByClassName('tooltip') | ||
| target.innerText = "Loading ..."; | ||
|
|
||
| const code = cache.get(url) || await fetch(url).then((response) => response.text()); |
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.
Using the url for cache doesn't work because it will return the same result for multiple warnings on the same file. So we have to generate a kind of unique id for each table line and handle the cache with it.
A simple code like this will do the job:
const lineId = Math.random().toString(36).slice(2);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.
Yeah.
My first idea was to cache the file if there are multiple errors on the same file. If I understand properly we should favor the memory size consuming over the network consuming. It's pretty obvious in fact ^^
I'll update this ^^
The sequence of instructions is more logical like this ^^ Thanks |
fraxken
left a comment
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.
|
Hi @fraxken Happy to read your feedback. Let me know about the tooltip position. Feel free to challenge me on this part. ✋ A little question: Should we keep somewhere interface definitions (like 👋 |
|
Hi @fraxken 👋 Following our previous discussion, I updated the behavior of the tooltip modal. We have now to click on the position cell to display the modal and click outside of the modal to close it. This commit, it's more about validating the behavior and the code than a final version. I prefer to be sure we agree on this before investing too much in detail. You'll see, it miss:
Let me know ^^ |
Hi @fraxken 👋
Very happy to submit you this pull request related the issue #48 ^^
I think we should consider the fact that each request to UNPKG should be cached. I'm not really opinionated about the way to do it. This is why I prefer to ask you first. I could propose something anyway.
A little preview:
