mirror of
https://github.com/lrsjng/h5ai.git
synced 2025-08-12 08:54:05 +02:00
Add chunksize to thumbnail requests.
This commit is contained in:
@@ -352,6 +352,7 @@
|
|||||||
- delay: number, delay in milliseconds after "dom-ready" before thumb-requesting starts
|
- delay: number, delay in milliseconds after "dom-ready" before thumb-requesting starts
|
||||||
- size: number, size in pixel of the generated thumbnails
|
- size: number, size in pixel of the generated thumbnails
|
||||||
- exif: boolean, use included EXIF thumbs if possible
|
- exif: boolean, use included EXIF thumbs if possible
|
||||||
|
- chunksize: int, number of thumbs per request
|
||||||
*/
|
*/
|
||||||
"thumbnails": {
|
"thumbnails": {
|
||||||
"enabled": true,
|
"enabled": true,
|
||||||
@@ -360,7 +361,8 @@
|
|||||||
"doc": ["x-pdf", "x-ps"],
|
"doc": ["x-pdf", "x-ps"],
|
||||||
"delay": 1,
|
"delay": 1,
|
||||||
"size": 240,
|
"size": 240,
|
||||||
"exif": false
|
"exif": false,
|
||||||
|
"chunksize": 20
|
||||||
},
|
},
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@@ -10,7 +10,8 @@ const settings = Object.assign({
|
|||||||
doc: ['x-pdf', 'x-ps'],
|
doc: ['x-pdf', 'x-ps'],
|
||||||
delay: 1,
|
delay: 1,
|
||||||
size: 100,
|
size: 100,
|
||||||
exif: false
|
exif: false,
|
||||||
|
chunksize: 20
|
||||||
}, allsettings.thumbnails);
|
}, allsettings.thumbnails);
|
||||||
const landscapeRatio = 4 / 3;
|
const landscapeRatio = 4 / 3;
|
||||||
|
|
||||||
@@ -71,7 +72,7 @@ const requestQueue = queue => {
|
|||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
server.request({
|
return server.request({
|
||||||
action: 'get',
|
action: 'get',
|
||||||
thumbs
|
thumbs
|
||||||
}).then(json => {
|
}).then(json => {
|
||||||
@@ -81,14 +82,19 @@ const requestQueue = queue => {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const breakAndRequestQueue = queue => {
|
||||||
|
const len = queue.length;
|
||||||
|
const chunksize = settings.chunksize;
|
||||||
|
let p = Promise.resolve();
|
||||||
|
for (let i = 0; i < len; i += chunksize) {
|
||||||
|
p = p.then(() => requestQueue(queue.slice(i, i + chunksize)));
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
const handleItems = items => {
|
const handleItems = items => {
|
||||||
const queue = [];
|
const queue = [];
|
||||||
|
|
||||||
each(items, item => queueItem(queue, item));
|
each(items, item => queueItem(queue, item));
|
||||||
|
breakAndRequestQueue(queue);
|
||||||
if (queue.length) {
|
|
||||||
requestQueue(queue);
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const onViewChanged = added => {
|
const onViewChanged = added => {
|
||||||
|
Reference in New Issue
Block a user