mirror of
https://github.com/Mintplex-Labs/anything-llm.git
synced 2025-03-16 07:02:22 +00:00
patch reveal hook
This commit is contained in:
parent
834fb5f900
commit
4afdf846e0
1 changed files with 4 additions and 6 deletions
|
@ -387,7 +387,7 @@ const SidebarOptions = ({ user = null, t }) => (
|
|||
flex={true}
|
||||
allowedRole={["admin"]}
|
||||
/>
|
||||
<HoldToReveal>
|
||||
<HoldToReveal key="exp_features">
|
||||
<Option
|
||||
href={paths.settings.experimental()}
|
||||
btnText="Experimental Features"
|
||||
|
@ -401,7 +401,7 @@ const SidebarOptions = ({ user = null, t }) => (
|
|||
);
|
||||
|
||||
function HoldToReveal({ children, holdForMs = 3_000 }) {
|
||||
let timeout;
|
||||
let timeout = null;
|
||||
const [showing, setShowing] = useState(
|
||||
window.localStorage.getItem(
|
||||
"anythingllm_experimental_feature_preview_unlocked"
|
||||
|
@ -410,13 +410,11 @@ function HoldToReveal({ children, holdForMs = 3_000 }) {
|
|||
|
||||
useEffect(() => {
|
||||
const onPress = (e) => {
|
||||
if (!["Control", "Meta"].includes(e.key)) return;
|
||||
if (!["Control", "Meta"].includes(e.key) || timeout !== null) return;
|
||||
timeout = setTimeout(() => {
|
||||
setShowing(true);
|
||||
// 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",
|
||||
});
|
||||
showToast("Experimental feature previews unlocked!");
|
||||
window.localStorage.setItem(
|
||||
"anythingllm_experimental_feature_preview_unlocked",
|
||||
"enabled"
|
||||
|
|
Loading…
Add table
Reference in a new issue