-
-
Notifications
You must be signed in to change notification settings - Fork 346
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
perf: reduce the number of left-click event listeners on files #148
perf: reduce the number of left-click event listeners on files #148
Conversation
Someone is attempting to deploy a commit to a Personal Account owned by @kimlimjustin on Vercel. @kimlimjustin first needs to authorize it. |
right and left confused lol |
This pull request is being automatically deployed with Vercel (learn more). 🔍 Inspect: https://vercel.com/kimlimjustin/xplorer/DuBNYD6LCyV17iwkVnjPYkvaQrCN |
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.
Overall it's a good job!
However, IDK if you noticed it but whenever you reload, the settings button automatically add ups
Untitled_.Oct.6.2021.2_23.PM.mp4
Could you please fix this?
Thanks!
Oops, ok. I will fix this problem a little later |
@kimlimjustin Hi. What is the purpose of this feature. Why in |
WDYM? What I meant is that your PR has a bug, which is the setting button (see the video left down area) is duplicating whenever I press the reload button, could you please fix it? (It's okay if you are not available, I could do it) |
I understood what the problem is. I don't really understand why in |
Eh, you remind me, calling the function in the reload function was because of the drive detection haven't been implemented at that time, and the drive detection works now, I think we can savely remove the function calling now :) |
Ok. Now this problem is gone |
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.
Yes, the setting problem gone, but here's another:
const openFileHandler = (e:Event):void => { | ||
let element = e.target as HTMLElement; | ||
while (!element.dataset.path) { | ||
element = element.parentNode as HTMLElement | ||
} | ||
const filePath = unescape(element.dataset.path) | ||
const openFileHandler = (e: Event): void => { | ||
const target = e.target as HTMLElement | ||
|
||
// Ignore workspace clicks | ||
if (target.id === 'workspace') return | ||
|
||
const element = target.dataset.path ? target : target.parentNode as HTMLElement, | ||
filePath = unescape(element.dataset.path); | ||
|
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.
Changing this introduce another bug, when you click exactly on a drive's name, a error came out,
Untitled_.Oct.8.2021.7_15.PM.mp4
this is because the target I clicked, pendrive-title
is under pendrive-info
div that is under the div that contains the dataset.path
, could you please fix this?
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.
Sorry, but today I changed my computer on which was Windows. Now i have a computer with Ubuntu. I didn't have such problems in Ubuntu. The computer with Windows will not be available to me for some time. So I cannot reliably verify that I have fixed it. So you can do it yourself or wait when I can.
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.
And I faced two problems on Ubuntu which I will now describe
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.
Ah okay, I'll fix it tonight (if I got time) or tomorrow
Motivation
Improve performance and simplify code
Changes
Instead of hanging left-click event listeners on each file and every time the directory is changed, now only two click listeners (
click
anddbclick
) are hung on their parents and only once. This allows significantly reduce the number of listeners created.Additional Comments
I guess the same can be done for the context menu