Skip to content
This repository has been archived by the owner on Nov 28, 2021. It is now read-only.

Bugfix/sound if no internet connection #19

Merged
merged 2 commits into from
May 8, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions src/appointments.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,11 @@ async function proceedWithACode(page: Page, impfCode: string) {
await appointmentWarning?.getProperty("innerText")
)?.jsonValue<string>();

if (await areWeOffline(page)) {
debug("We are offline or on some different page");
return false;
}

if (
!appointmentWarning ||
!appointmentText ||
Expand All @@ -107,6 +112,7 @@ async function proceedWithACode(page: Page, impfCode: string) {
debug("No appointments");
return false;
}

export async function proceedWithoutACode(page: Page) {
debug("Checking without a code");
// no, we have no code
Expand All @@ -124,6 +130,11 @@ export async function proceedWithoutACode(page: Page) {

const appointmentWarning = await page.$("div.alert.alert-danger");

if (await areWeOffline(page)) {
debug("We are offline or on some different page");
return false;
}

if (!appointmentWarning) {
// code available
debug("Appointments available!!");
Expand All @@ -133,6 +144,10 @@ export async function proceedWithoutACode(page: Page) {
return false;
}

async function areWeOffline(page: Page) {
return !(await page.$("footer-copyright"));
}

export async function checkForAppointments(
page: Page,
impfLocationUrl: string,
Expand Down