From b2a222d7e857c3f0b1722a1ef63c5f67da050935 Mon Sep 17 00:00:00 2001 From: Paul Date: Sun, 14 Nov 2021 18:51:19 +0000 Subject: [PATCH] fix: prevent native settings being opened on non-native fixes #344 --- src/pages/settings/Settings.tsx | 15 +++++++++------ src/pages/settings/panes/Native.tsx | 3 +++ 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/src/pages/settings/Settings.tsx b/src/pages/settings/Settings.tsx index bf27eab4..594421d9 100644 --- a/src/pages/settings/Settings.tsx +++ b/src/pages/settings/Settings.tsx @@ -25,6 +25,8 @@ import styles from "./Settings.module.scss"; import { Text } from "preact-i18n"; import { useContext } from "preact/hooks"; +import { isExperimentEnabled } from "../../redux/reducers/experiments"; + import RequiresOnline from "../../context/revoltjs/RequiresOnline"; import { AppContext, @@ -50,7 +52,6 @@ import { Profile } from "./panes/Profile"; import { Sessions } from "./panes/Sessions"; import { Sync } from "./panes/Sync"; import { ThemeShop } from "./panes/ThemeShop"; -import { isExperimentEnabled } from "../../redux/reducers/experiments"; export default function Settings() { const history = useHistory(); @@ -126,14 +127,14 @@ export default function Settings() { title: , }, { - divider: !isExperimentEnabled('theme_shop'), + divider: !isExperimentEnabled("theme_shop"), category: "revolt", id: "bots", icon: , title: , }, { - hidden: !isExperimentEnabled('theme_shop'), + hidden: !isExperimentEnabled("theme_shop"), divider: true, id: "theme_shop", icon: , @@ -179,9 +180,11 @@ export default function Settings() { - {isExperimentEnabled('theme_shop') && - - } + {isExperimentEnabled("theme_shop") && ( + + + + )} diff --git a/src/pages/settings/panes/Native.tsx b/src/pages/settings/panes/Native.tsx index 68580f44..0a0e766e 100644 --- a/src/pages/settings/panes/Native.tsx +++ b/src/pages/settings/panes/Native.tsx @@ -4,6 +4,9 @@ import Button from "../../../components/ui/Button"; import Checkbox from "../../../components/ui/Checkbox"; export function Native() { + if (typeof window.native === "undefined") return null; + /* eslint-disable react-hooks/rules-of-hooks */ + const [config, setConfig] = useState(window.native.getConfig()); const [autoStart, setAutoStart] = useState(); const fetchValue = () => window.native.getAutoStart().then(setAutoStart);