Display 5 thinned out screenshots as thumbnails
All checks were successful
continuous-integration/drone Build is passing
All checks were successful
continuous-integration/drone Build is passing
This commit is contained in:
parent
45fb0ea4f4
commit
37e9e061d4
14
index.ts
14
index.ts
@ -24,6 +24,18 @@ const signer = async function (asset: string) {
|
||||
return await presigner.presign(new HttpRequest(s3ObjectUrl));
|
||||
}
|
||||
|
||||
const shots = 5
|
||||
const reduceScreenshots = function (screenshots: Array<any>) {
|
||||
if (screenshots.length <= shots)
|
||||
return screenshots
|
||||
else
|
||||
var sc = []
|
||||
for (let i = 0; i < shots; i++) {
|
||||
sc.push(screenshots[i * Math.floor((screenshots.length - 1) / (shots - 1))])
|
||||
}
|
||||
return sc
|
||||
}
|
||||
|
||||
const getScreenshots = async function (resp: object, path: string): Promise<any> {
|
||||
const screenshots = resp.screenshots ? resp.screenshots : []
|
||||
if (path === '/details/') {
|
||||
@ -34,7 +46,7 @@ const getScreenshots = async function (resp: object, path: string): Promise<any>
|
||||
}
|
||||
});
|
||||
} else if (path === '/initial/' || path === '/query/' || path === '/streaming/') {
|
||||
return screenshots.splice(0, 5).map(async (x) => {
|
||||
return reduceScreenshots(screenshots).map(async (x) => {
|
||||
return {
|
||||
thumb: formatUrl(await signer(`thumb/${x}`)),
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user