Hotfix to keep from checks breaking when entering a new scene.
This commit is contained in:
parent
b8c4dbe022
commit
25f664ee4e
@ -79,7 +79,6 @@ async function initialize_elements() {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Initialize global state
|
// Initialize global state
|
||||||
current_checks = checks.collected + checks.found;
|
current_checks = checks.collected + checks.found;
|
||||||
current_entrances = entrances.found;
|
current_entrances = entrances.found;
|
||||||
@ -136,9 +135,9 @@ async function refresh_elements() {
|
|||||||
}
|
}
|
||||||
is_timeout = false;
|
is_timeout = false;
|
||||||
await update_if_changes(response.data);
|
await update_if_changes(response.data);
|
||||||
setTimeout(refresh_elements, 500)
|
setTimeout(refresh_elements, 500);
|
||||||
} else if (response.error) {
|
} else if (response.error) {
|
||||||
setTimeout(refresh_elements, 1100)
|
setTimeout(refresh_elements, 1100);
|
||||||
if (response.error.error) {
|
if (response.error.error) {
|
||||||
if (!is_timeout) {
|
if (!is_timeout) {
|
||||||
is_timeout = true;
|
is_timeout = true;
|
||||||
@ -162,14 +161,11 @@ async function refresh_elements() {
|
|||||||
document.getElementById("status-block").classList.remove("hidden");
|
document.getElementById("status-block").classList.remove("hidden");
|
||||||
}
|
}
|
||||||
can_access_api_server = false;
|
can_access_api_server = false;
|
||||||
setTimeout(refresh_elements, 1100)
|
setTimeout(refresh_elements, 1100);
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
setTimeout(refresh_elements, 1100)
|
setTimeout(refresh_elements, 1100);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async function update_if_changes(overview) {
|
async function update_if_changes(overview) {
|
||||||
@ -574,7 +570,9 @@ async function initialize_checks_list(checks_list, checks) {
|
|||||||
// Update the check totals
|
// Update the check totals
|
||||||
checks_list.querySelector(
|
checks_list.querySelector(
|
||||||
".breakdown-block-checks-title"
|
".breakdown-block-checks-title"
|
||||||
).textContent = `Checks: ${checks.collected + checks.found}/${checks.total} (${checks.remaining} left)`;
|
).textContent = `Checks: ${checks.collected + checks.found}/${
|
||||||
|
checks.total
|
||||||
|
} (${checks.remaining} left)`;
|
||||||
checks_list.querySelector(
|
checks_list.querySelector(
|
||||||
".breakdown-block-checks-title"
|
".breakdown-block-checks-title"
|
||||||
).dataset.checksCollected = checks.collected + checks.found;
|
).dataset.checksCollected = checks.collected + checks.found;
|
||||||
@ -725,7 +723,9 @@ async function initialize_summary(summary_element, scene, checks, entrances) {
|
|||||||
summary_checks.dataset.checksCollected = checks.collected + checks.found;
|
summary_checks.dataset.checksCollected = checks.collected + checks.found;
|
||||||
summary_checks.dataset.checksRemaining = checks.remaining;
|
summary_checks.dataset.checksRemaining = checks.remaining;
|
||||||
summary_checks.dataset.checksTotal = checks.total;
|
summary_checks.dataset.checksTotal = checks.total;
|
||||||
summary_checks.textContent = `Checks: ${checks.collected + checks.found}/${checks.total} (${checks.remaining})`;
|
summary_checks.textContent = `Checks: ${checks.collected + checks.found}/${
|
||||||
|
checks.total
|
||||||
|
} (${checks.remaining})`;
|
||||||
|
|
||||||
const summary_entrances = summary_element.querySelector(".summary-entrances");
|
const summary_entrances = summary_element.querySelector(".summary-entrances");
|
||||||
summary_entrances.dataset.entrancesFound = entrances.found;
|
summary_entrances.dataset.entrancesFound = entrances.found;
|
||||||
@ -787,7 +787,9 @@ async function update_summary(scene, checks, entrances) {
|
|||||||
summary_checks.dataset.checksCollected = checks.collected + checks.found;
|
summary_checks.dataset.checksCollected = checks.collected + checks.found;
|
||||||
summary_checks.dataset.checksRemaining = checks.remaining;
|
summary_checks.dataset.checksRemaining = checks.remaining;
|
||||||
summary_checks.dataset.checksTotal = checks.total;
|
summary_checks.dataset.checksTotal = checks.total;
|
||||||
summary_checks.textContent = `Checks: ${checks.collected + checks.found}/${checks.total} (${checks.remaining})`;
|
summary_checks.textContent = `Checks: ${checks.collected + checks.found}/${
|
||||||
|
checks.total
|
||||||
|
} (${checks.remaining})`;
|
||||||
}
|
}
|
||||||
if (entrances_changed) {
|
if (entrances_changed) {
|
||||||
summary_entrances.dataset.entrancesFound = entrances.found;
|
summary_entrances.dataset.entrancesFound = entrances.found;
|
||||||
@ -856,7 +858,9 @@ async function update_breakdown_checks(scene, checks) {
|
|||||||
// Update the check totals
|
// Update the check totals
|
||||||
document.querySelector(
|
document.querySelector(
|
||||||
`.breakdown[data-scene="${scene}"] .breakdown-block-checks-title`
|
`.breakdown[data-scene="${scene}"] .breakdown-block-checks-title`
|
||||||
).textContent = `Checks: ${checks.collected + checks.found}/${checks.total} (${checks.remaining} left)`;
|
).textContent = `Checks: ${checks.collected + checks.found}/${
|
||||||
|
checks.total
|
||||||
|
} (${checks.remaining} left)`;
|
||||||
document.querySelector(
|
document.querySelector(
|
||||||
`.breakdown[data-scene="${scene}"] .breakdown-block-checks-title`
|
`.breakdown[data-scene="${scene}"] .breakdown-block-checks-title`
|
||||||
).dataset.checksCollected = checks.collected + checks.found;
|
).dataset.checksCollected = checks.collected + checks.found;
|
||||||
@ -925,7 +929,10 @@ async function update_breakdown(scene, checks, entrances) {
|
|||||||
);
|
);
|
||||||
|
|
||||||
// Check for changes, and if so, update
|
// Check for changes, and if so, update
|
||||||
if (breakdown_checks.dataset.checksCollected != checks.collected + checks.found) {
|
if (
|
||||||
|
breakdown_checks.dataset.checksCollected !=
|
||||||
|
checks.collected + checks.found
|
||||||
|
) {
|
||||||
update_breakdown_checks(scene, checks);
|
update_breakdown_checks(scene, checks);
|
||||||
}
|
}
|
||||||
if (breakdown_entrances.dataset.entrancesFound != entrances.found) {
|
if (breakdown_entrances.dataset.entrancesFound != entrances.found) {
|
||||||
@ -948,9 +955,12 @@ async function update_breakdown_list(data, changed) {
|
|||||||
update_breakdown(
|
update_breakdown(
|
||||||
scene,
|
scene,
|
||||||
{
|
{
|
||||||
collected: document.querySelector(
|
collected: parseInt(
|
||||||
|
document.querySelector(
|
||||||
`.breakdown[data-scene="${scene}"] .breakdown-block-checks-title`
|
`.breakdown[data-scene="${scene}"] .breakdown-block-checks-title`
|
||||||
).dataset.checksCollected,
|
).dataset.checksCollected
|
||||||
|
),
|
||||||
|
found: 0,
|
||||||
},
|
},
|
||||||
data.scenes[scene]
|
data.scenes[scene]
|
||||||
)
|
)
|
||||||
|
Loading…
Reference in New Issue
Block a user