Display current action while polling screenshots
This commit is contained in:
parent
f4f287a3bb
commit
61e01c5244
|
@ -20,6 +20,7 @@ type Screenshot = {
|
||||||
interface screenshotTask {
|
interface screenshotTask {
|
||||||
domains: string[];
|
domains: string[];
|
||||||
elapsed_time_s: number;
|
elapsed_time_s: number;
|
||||||
|
current_action: string;
|
||||||
finished_time: number;
|
finished_time: number;
|
||||||
id: string;
|
id: string;
|
||||||
images: Screenshot[];
|
images: Screenshot[];
|
||||||
|
@ -68,6 +69,7 @@ export default function ScreenshotGenerator({
|
||||||
const [images, setImages] = React.useState<Screenshot[]>([]);
|
const [images, setImages] = React.useState<Screenshot[]>([]);
|
||||||
const [taskId, setTaskId] = React.useState<string | null>(null);
|
const [taskId, setTaskId] = React.useState<string | null>(null);
|
||||||
const [output, setOutput] = React.useState<any>({});
|
const [output, setOutput] = React.useState<any>({});
|
||||||
|
const [currentAction, setCurrentAction] = React.useState<string>('');
|
||||||
|
|
||||||
async function subscribeTask(path: string): Promise<screenshotTask> {
|
async function subscribeTask(path: string): Promise<screenshotTask> {
|
||||||
let response = { status: taskState.WAITING };
|
let response = { status: taskState.WAITING };
|
||||||
|
@ -75,6 +77,7 @@ export default function ScreenshotGenerator({
|
||||||
await new Promise((resolve) => setTimeout(resolve, 1000));
|
await new Promise((resolve) => setTimeout(resolve, 1000));
|
||||||
response = await (await pollTask(path)).json();
|
response = await (await pollTask(path)).json();
|
||||||
setImages((response as screenshotTask)?.images);
|
setImages((response as screenshotTask)?.images);
|
||||||
|
setCurrentAction((response as screenshotTask)?.current_action);
|
||||||
document.querySelector('.images')?.scrollTo({
|
document.querySelector('.images')?.scrollTo({
|
||||||
top: document.querySelector('.images')?.scrollHeight,
|
top: document.querySelector('.images')?.scrollHeight,
|
||||||
behavior: 'smooth',
|
behavior: 'smooth',
|
||||||
|
@ -156,6 +159,7 @@ export default function ScreenshotGenerator({
|
||||||
Nasz serwer właśnie odwiedza wskazaną przez Ciebie stronę
|
Nasz serwer właśnie odwiedza wskazaną przez Ciebie stronę
|
||||||
i przygotowuje zrzuty ekranów narzędzi deweloperskich.
|
i przygotowuje zrzuty ekranów narzędzi deweloperskich.
|
||||||
</p>
|
</p>
|
||||||
|
<div>{currentAction}</div>
|
||||||
</Fragment>
|
</Fragment>
|
||||||
) : null}
|
) : null}
|
||||||
{mode === 'finished' ? (
|
{mode === 'finished' ? (
|
||||||
|
|
Loading…
Reference in New Issue
Block a user