pg: fix eslint no-async-promise-executor

This commit is contained in:
Ralf Vogler 2025-05-22 22:40:08 +02:00
parent 0e00cfd7fb
commit 2bd12a986e

View file

@ -131,20 +131,18 @@ try {
// bottom to top: oldest to newest games // bottom to top: oldest to newest games
internal.reverse(); internal.reverse();
external.reverse(); external.reverse();
// TODO just use async, no need for Promise? -> type error since now Page | bool instead of any const sameOrNewPage = async url => {
// eslint-disable-next-line no-async-promise-executor
const sameOrNewPage = async url => new Promise(async (resolve, _reject) => {
const isNew = page.url() != url; const isNew = page.url() != url;
let p = page; let p = page;
if (isNew) { if (isNew) {
p = await context.newPage(); p = await context.newPage();
await p.goto(url, { waitUntil: 'domcontentloaded' }); await p.goto(url, { waitUntil: 'domcontentloaded' });
} }
resolve([p, isNew]); return { p, isNew };
}); };
const skipBasedOnTime = async url => { const skipBasedOnTime = async url => {
// console.log(' Checking time left for game:', url); // console.log(' Checking time left for game:', url);
const [p, isNew] = await sameOrNewPage(url); const { p, isNew } = await sameOrNewPage(url);
const dueDateOrg = await p.locator('.availability-date .tw-bold').innerText(); const dueDateOrg = await p.locator('.availability-date .tw-bold').innerText();
const dueDate = new Date(Date.parse(dueDateOrg + ' 17:00')); const dueDate = new Date(Date.parse(dueDateOrg + ' 17:00'));
const daysLeft = (dueDate.getTime() - Date.now()) / 1000 / 60 / 60 / 24; const daysLeft = (dueDate.getTime() - Date.now()) / 1000 / 60 / 60 / 24;