#569 Use main API as summary source

This commit is contained in:
Cohee
2023-06-30 23:37:01 +03:00
parent fe8db4ded8
commit cba2feb875
3 changed files with 237 additions and 37 deletions

View File

@ -651,3 +651,20 @@ export function createThumbnail(dataUrl, maxWidth, maxHeight) {
};
});
}
export async function waitUntilCondition(condition, timeout = 1000, interval = 100) {
return new Promise((resolve, reject) => {
const timeoutId = setTimeout(() => {
clearInterval(intervalId);
reject(new Error('Timed out waiting for condition to be true'));
}, timeout);
const intervalId = setInterval(() => {
if (condition()) {
clearTimeout(timeoutId);
clearInterval(intervalId);
resolve();
}
}, interval);
});
}