Fix bug with solved puzzle tracking

This commit is contained in:
Neale Pickett 2024-04-17 17:17:58 -06:00
parent 91ab94dade
commit 259ad59755
4 changed files with 25 additions and 12 deletions

View File

@ -4,6 +4,10 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
## [v4.6.1] - 2024-04-17
### Changed
- Fixed bug with solved puzzle tracking when config.json cannot be loaded.
## [v4.6.0] - 2024-04-17 ## [v4.6.0] - 2024-04-17
### Changed ### Changed
- Mothd now correctly handles using the current directory for a path. - Mothd now correctly handles using the current directory for a path.

View File

@ -48,7 +48,7 @@ function WhenDOMLoaded(cb) {
* @param {String} s * @param {String} s
* @returns {Boolean} * @returns {Boolean}
*/ */
function Truthy(s) { function StringTruthy(s) {
switch (s.toLowerCase()) { switch (s.toLowerCase()) {
case "disabled": case "disabled":
case "no": case "no":
@ -66,13 +66,20 @@ function Truthy(s) {
* @returns {Promise.<Object>} * @returns {Promise.<Object>}
*/ */
async function Config() { async function Config() {
let resp = await fetch( let obj = {}
new URL("config.json", BaseURL), try {
{ let resp = await fetch(
cache: "no-cache" new URL("configg.json", BaseURL),
}, {
) cache: "no-cache"
return resp.json() },
)
obj = await resp.json()
}
catch(err) {
obj = {}
}
return obj
} }
export { export {
@ -83,6 +90,6 @@ export {
BaseURL, BaseURL,
Toast, Toast,
WhenDOMLoaded, WhenDOMLoaded,
Truthy, StringTruthy,
Config, Config,
} }

View File

@ -29,7 +29,7 @@
Solved puzzle tracking: <b>disabled</b>. Solved puzzle tracking: <b>disabled</b>.
</p> </p>
<p> <p>
Your team's Incident Coordinator can help coordinate team activity. To avoid duplication of work, your team should coordinate.
</p> </p>
</div> </div>

View File

@ -92,8 +92,10 @@ class App {
// Update elements with data-track-solved // Update elements with data-track-solved
for (let e of document.querySelectorAll("[data-track-solved]")) { for (let e of document.querySelectorAll("[data-track-solved]")) {
// Only display if data-track-solved is the same as config.trackSolved // Only hide if data-track-solved is different than config.PuzzleList.TrackSolved
e.classList.toggle("hidden", common.Truthy(e.dataset.trackSolved) != this.config.PuzzleList?.TrackSolved) let tracking = this.config.PuzzleList?.TrackSolved || false
let displayIf = common.StringTruthy(e.dataset.trackSolved)
e.classList.toggle("hidden", tracking != displayIf)
} }
for (let e of document.querySelectorAll(".login")) { for (let e of document.querySelectorAll(".login")) {