-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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
Prefetch previous and next images in preview. #1627
Conversation
great improvement.. i reviewed the code and looks good.. please @o1egl .. |
Yes, I also think it's cool. |
All fixed. #1627 (comment) #1627 (comment) ... So here we need change the previousLink from /files/... to ${baseURL}/api/preview/big/...., slice(6) will delete the first 6 characters "/files", and ${baseURL}/api/preview/big${this.previousLink.slice(6)}?k=${key}` will get the whole path for the previous and next raw. You can check all the required path format using console.log. #1627 (comment) |
#1627 (comment) |
You are using the slice() method, making hard to understand the code. Using the file fields to construct the URL is more descriptive. |
Yes, we need to use console.log to see the difference of the path formats. |
@ramiresviana |
@niubility000 please address that comment before merging this PR |
It's not necessary to use the file fields to construct the URL. As @ramiresviana said, it will not make it faster, just make it more descriptive for the coder to read. Currently we just calculate the prefetch link in the same way as we calculate the raw path. I think it's fine, it's easy to understand. |
I would prefer to explicitly construct URL instead of making manipulations on the current path |
Co-authored-by: Ramires Viana <59319979+ramiresviana@users.noreply.github.com>
Co-authored-by: Ramires Viana <59319979+ramiresviana@users.noreply.github.com>
Co-authored-by: Ramires Viana <59319979+ramiresviana@users.noreply.github.com>
Thank you, @ramiresviana, |
This will auto prefetch the previous and next images in preview. A very useful feature! Most of other projects have this one.
The effects will be more obvious if your Internet speed is low. So using a cellphone (close wifi) to test it. It's very fast to show the previous or next pic when you switch.
Filebrowser uses "lazy load", "cache", "prefetch imgs", and it can disable preview resize, disable type detection by header. All of these make filebrowser the fastest and most stable project compared with others. And it's written in golang, which allows it to run in low-end servers.
Very good.