You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
28 lines
748 B
28 lines
748 B
import type { Page } from "playwright";
|
|
import type { AxelSelectionBridge } from "@/workers/rpa/axel-selection-bridge";
|
|
import { TRIGGER_GOOGLE_PLACE_CHANGED } from "@/workers/rpa/fix-place/browser-eval-scripts";
|
|
|
|
const PLACE_COMMIT_TIMEOUT_MS = 8_000;
|
|
|
|
export async function commitViaGooglePlaceEvent(
|
|
page: Page,
|
|
bridge: AxelSelectionBridge,
|
|
placeId: string,
|
|
description: string,
|
|
): Promise<{ ok: boolean }> {
|
|
const result = (await page.evaluate(TRIGGER_GOOGLE_PLACE_CHANGED, {
|
|
pid: placeId,
|
|
desc: description,
|
|
})) as { ok?: boolean } | null;
|
|
|
|
if (!result?.ok) {
|
|
return { ok: false };
|
|
}
|
|
|
|
const committed = await bridge.waitForPlaceCommit(
|
|
placeId,
|
|
PLACE_COMMIT_TIMEOUT_MS,
|
|
);
|
|
return { ok: committed };
|
|
}
|