-
Notifications
You must be signed in to change notification settings - Fork 102
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
feat: display openrank information in developer information hover card #832
Conversation
Hi Tenth, thanks for your work! It is good to have a draft PR to discuss. To answer your question, why it is not working. I think it is because the element with avatar does not have id Also, the use of Feel free to reach out if you have further questions. I would love to help. 😸 |
Thanks! i will try it later |
Thanks for your reply again.Through your code, I have a deeper understanding of the event monitoring method. Now I can import OpenRank information, but I found that when the mouse hovers over the avatar for the first few hundred milliseconds, OpenRank information appears in That is, when the floating card appears, it is based on the user data obtained by the GitHub script, and cannot display the OpenRank information we introduced. I don't know much about GitHub scripts. Is there any way to make our information display correctly instead of being constantly overwritten? If so, I'd like to try it! If there is no feasible method, I thought of another solution, which is to create a new container to present the openrank information instead of using |
I am not sure what that is but I don't think it is a good way to change the inner content of that element becuase it is just a string and we don't know how Github parse it. I would recommend inserting data to the hovercard direclty when it pops up. We can improve the performance somehow by caching the user info to prevent constantly requesting data. Let me know what you think. |
From my observation, |
I am not sure this is what we want. From the description, I was expecting something like this: 2024-07-16.19.36.32-1.movLet me know if you have any concerns or troubles. We can also schedule a meeting to discuss if you want. |
I think what you showed in your video is the expected result of the original issue. How did you do it? |
I followed the code in this comment #832 (comment) |
Based on the code you showed in #832, here is my code, but my result is as shown in the video, I added the content to the end of the card information, but it was overwritten afterwards
vedio1.mp4 |
I used |
Thanks, I'll try it soon! |
Thank you for your guidance these days. Without your guidance, I think it would be difficult for me to complete this task. I am sorry for asking so many stupid questions because I don't understand the front-end structure. Under your guidance, I completed this task. Thank you very much. You are an excellent open source contributor and a good teacher. This is my latest presentation result. If it meets the requirements, I am ready to review it. success.mp4 |
Thanks! It is nice to work with you, I am glad you finally made it and I also learned a lot myself during this process. However, we are not there yet, there are things we need to add before reviewing it carefully:
BTW, Let's change the name |
Thank you for your comments, I have now completed the changes you requested and fixed the bugs I could find. And I tested the performance of the function in dark mode, now I believe you can see the openrank information clearly. |
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.
Nice work! I have set this PR to ready to review. Thanks a lot!
There is something wrong with the insertion. It is not showing the info after a click(?). Could look into it?
2024-07-18.22.50.39-1.mov
src/pages/ContentScripts/features/developer-hovercard-info/view.tsx
Outdated
Show resolved
Hide resolved
src/pages/ContentScripts/features/developer-hovercard-info/view.tsx
Outdated
Show resolved
Hide resolved
src/pages/ContentScripts/features/developer-hovercard-info/view.tsx
Outdated
Show resolved
Hide resolved
src/pages/ContentScripts/features/developer-hovercard-info/view.tsx
Outdated
Show resolved
Hide resolved
src/pages/ContentScripts/features/developer-hovercard-info/index.tsx
Outdated
Show resolved
Hide resolved
src/pages/ContentScripts/features/developer-hovercard-info/index.tsx
Outdated
Show resolved
Hide resolved
I will edit it later |
It is not clear how the bug occurred. The information can still be displayed after I click it. I will find the cause of the bug later. |
I was testing your work. This is amazing. Thank you so much! Besides this bug, there are two chinese comments in the view index.tsx file, I think we can remove them. If you want me to help with the bug, just let me know. |
src/pages/ContentScripts/features/developer-hovercard-info/index.tsx
Outdated
Show resolved
Hide resolved
src/pages/ContentScripts/features/developer-hovercard-info/index.tsx
Outdated
Show resolved
Hide resolved
Sorry I missed them due to my negligence, they have been removed now. Regarding the bug situation, it would be very helpful if you can find the possible cause. |
I think it is the
but I got an another one while trying hovering really quick. It is not working properly somehow. We need to handle this better. 2024-07-21.01.31.33.mov |
This variable was originally used to prevent re-addition. It has worked well for me before, but now there seems to be some problems. I will deal with it later. |
I tried to move the mouse back and forth on the edge of the avatar, but the information was not repeated. However, I have added the solution you mentioned into my code. I have used isProcessing and the developer name to prevent duplicate additions, but there is still a situation that causes duplicate additions. That is, when the mouse quickly passes over the id and avatar, the information will be added twice because it is the same name. However, in theory, the following code should prevent duplicate additions.
Sometimes the information is not displayed, but I am sure that OpenRank can be found. I also found that it was successfully displayed at the beginning, but it did not display after repeated several times. I still don’t know the reason. |
It is not showing because listener event functions are fired at the same time, and the latter one is prevented by the former one while the hovercard that the former one added is closed. const init = async (): Promise<void> => {
let abortController = new AbortController()
const hovercardSelector = '[data-hovercard-type="user"]';
document.querySelectorAll(hovercardSelector).forEach((element) => {
// isProcessing is used to Prevent OpenRank from adding duplicates
element.addEventListener('mouseover', async () => {
abortController.abort();
abortController = new AbortController();
const signal = abortController.signal;
const developerName = getDeveloperName(element as HTMLElement) as string;
// Create a unique identifier for the popover
const popoverId = `popover-${developerName}`;
// Get the floating card container
const $popoverContainer =
'body > div.logged-in.env-production.page-responsive > div.Popover.js-hovercard-content.position-absolute > div > div > div';
const popover = await elementReady($popoverContainer, { stopOnDomReady: false });
const openRankDiv = popover?.querySelector('.openrank-info-container');
const existingDeveloperName = openRankDiv?.getAttribute('data-developer-name');
if (existingDeveloperName === developerName) {
return;
}
openRankDiv?.remove();
// Set the popover's unique identifier
// make the current OpenRank information and person match
popover?.setAttribute('data-popover-id', popoverId);
const openrank = await getDeveloperLatestOpenrank(developerName);
if (!openrank) {
return;
}
if (!signal.aborted && popover && popover.getAttribute('data-popover-id') === popoverId) {
// Check if the popover is still associated with the correct developer
renderTo(popover, developerName, openrank);
}
});
});
}; While this may fix the |
I have made some changes based on your code. Thanks to your code, I have a better understanding of asynchronous operations. Now the information can be displayed normally in most cases. At least I have not encountered the situation where it is no longer displayed. |
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.
LGTM. Nicely done, it is a great contribution. Thank you so much!
Brief Information
This pull request is in the type of (more info about types):
Related issues: [Task 6 Display extra information from OpenDigger in the developer information hover card]#810
Details
Checklist
Others
I'm sorry that a previous commit was lost, leaving only the run prettier commit
I haven't completed the task yet. I want to ask through this draft PR why my code doesn't work and I can't find the error.