mirror of
https://github.com/ivabus/gui
synced 2025-04-23 05:57:11 +03:00
load image faster: do not preload if url is local (#563)
Co-authored-by: neil molina <neil@neils-MacBook-Pro.local>
This commit is contained in:
parent
ae02ff020a
commit
34161aebea
1 changed files with 7 additions and 1 deletions
|
@ -16,6 +16,12 @@
|
|||
let lastProcessedPkg: GUIPackage | null = null;
|
||||
|
||||
const loadImage = async (url: string): Promise<string> => {
|
||||
if (url.includes("cached_images")) {
|
||||
loadedImg = url;
|
||||
loaded = true;
|
||||
return url;
|
||||
}
|
||||
|
||||
const image = new Image();
|
||||
image.src = url;
|
||||
return new Promise((resolve, reject) => {
|
||||
|
@ -23,7 +29,7 @@
|
|||
loadedImg = url;
|
||||
setTimeout(() => {
|
||||
loaded = true;
|
||||
}, 300);
|
||||
}, 100);
|
||||
resolve(url);
|
||||
};
|
||||
image.onerror = () => {
|
||||
|
|
Loading…
Reference in a new issue