From d9cfcba9bb39a2087d3647d980c6898e5878c9d5 Mon Sep 17 00:00:00 2001
From: timothycarambat <rambat1010@gmail.com>
Date: Wed, 26 Jun 2024 23:48:38 -0700
Subject: [PATCH] prevent holdToReveal from spamming toasts

---
 frontend/src/components/SettingsSidebar/index.jsx | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/frontend/src/components/SettingsSidebar/index.jsx b/frontend/src/components/SettingsSidebar/index.jsx
index 112be3120..83b0075f0 100644
--- a/frontend/src/components/SettingsSidebar/index.jsx
+++ b/frontend/src/components/SettingsSidebar/index.jsx
@@ -413,7 +413,10 @@ function HoldToReveal({ children, holdForMs = 3_000 }) {
       if (!["Control", "Meta"].includes(e.key)) return;
       timeout = setTimeout(() => {
         setShowing(true);
-        showToast("Experimental feature previews unlocked!");
+        // Setting toastId prevents hook spam from holding control too many times or the event not detaching
+        showToast("Experimental feature previews unlocked!", {
+          toastId: "anythingllm_experimental_feature_preview_unlocked",
+        });
         window.localStorage.setItem(
           "anythingllm_experimental_feature_preview_unlocked",
           "enabled"
-- 
GitLab