From 2401f9b958c254820a052e8a79e9411f993303d8 Mon Sep 17 00:00:00 2001 From: CatAClock Date: Wed, 11 Jun 2025 18:42:24 -0700 Subject: [PATCH] race condition potential fix --- JS/expanded.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/JS/expanded.js b/JS/expanded.js index baf7aa4..7767cc0 100644 --- a/JS/expanded.js +++ b/JS/expanded.js @@ -10,6 +10,8 @@ let Reply = document.getElementsByClassName("Reply")[0]; let FavoriteFlipper = false; let BoostFlipper = false; +let Favoritable = false; +let Boostable = false; // Variables let website = document.location.href.split("website=")[1]; @@ -25,6 +27,10 @@ let EmbedCounter = 0; // Button stuff Favorite.onclick = (event) => { + if (Favoritable == false) { + return; + } + Favoritable = false; if (website == "Mastodon") { MastodonAPI.CreateFavorite(post.id, post.favourited); } else if (website == "Bluesky") { @@ -34,6 +40,10 @@ Favorite.onclick = (event) => { } Boost.onclick = (event) => { + if (Boostable == false) { + return; + } + Boostable = false; if (website == "Mastodon") { MastodonAPI.CreateReblog(post.id, post.reblogged); } else if (website == "Bluesky") { @@ -271,6 +281,7 @@ function SetFavorite() { } else { Favorite.innerHTML = "Unfavorite..."; } + Favoritable = true; } function SetBoost() { @@ -280,6 +291,7 @@ function SetBoost() { } else { Boost.innerHTML = "Unboost..."; } + Boostable = true; } // Functions stolen form elsewhere