From ad7fc8f3b305d3a0040e6623cfe97286384209a3 Mon Sep 17 00:00:00 2001 From: Kwack Date: Mon, 16 Sep 2024 00:06:41 +0800 Subject: [PATCH] Fix: Gym Graph race condition where the dark mode toggle didn't yet exist (only reproduced on FF) (#807) Co-authored-by: Sashank <76554862+Sashank999@users.noreply.github.com> --- extension/changelog.json | 5 ++++- extension/scripts/features/gym-graph/ttGymGraph.js | 4 ++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/extension/changelog.json b/extension/changelog.json index c6317accb..30050d4d4 100644 --- a/extension/changelog.json +++ b/extension/changelog.json @@ -5,7 +5,10 @@ "date": false, "logs": { "features": [], - "fixes": [{ "message": "Copy Post for Discord not working due to layout changes.", "contributor": "TheFoxMan" }], + "fixes": [ + { "message": "Copy Post for Discord not working due to layout changes.", "contributor": "TheFoxMan" }, + { "message": "Fixed a race condition breaking the Gym Graph on Firefox", "contributor": "Kwack" } + ], "changes": [], "removed": [] } diff --git a/extension/scripts/features/gym-graph/ttGymGraph.js b/extension/scripts/features/gym-graph/ttGymGraph.js index 5674cc167..7147eed69 100644 --- a/extension/scripts/features/gym-graph/ttGymGraph.js +++ b/extension/scripts/features/gym-graph/ttGymGraph.js @@ -132,13 +132,13 @@ const gymChart = createChart(); // If Torn dark mode is toggled. - document.find("#dark-mode-state").addEventListener("change", (event) => { + await requireElement("#dark-mode-state").then((el) => el.addEventListener("change", (event) => { const color = event.target.checked ? "#fff" : "#000"; gymChart.options.scales.x.ticks.color = color; gymChart.options.scales.y.ticks.color = color; gymChart.options.plugins.legend.labels.color = color; gymChart.update(); - }); + })); showLoadingPlaceholder(wrapper, false);