fix: prevent native settings being opened on non-native

fixes #344
This commit is contained in:
Paul 2021-11-14 18:51:19 +00:00
parent b938f6620b
commit b2a222d7e8
2 changed files with 12 additions and 6 deletions

View file

@ -25,6 +25,8 @@ import styles from "./Settings.module.scss";
import { Text } from "preact-i18n"; import { Text } from "preact-i18n";
import { useContext } from "preact/hooks"; import { useContext } from "preact/hooks";
import { isExperimentEnabled } from "../../redux/reducers/experiments";
import RequiresOnline from "../../context/revoltjs/RequiresOnline"; import RequiresOnline from "../../context/revoltjs/RequiresOnline";
import { import {
AppContext, AppContext,
@ -50,7 +52,6 @@ import { Profile } from "./panes/Profile";
import { Sessions } from "./panes/Sessions"; import { Sessions } from "./panes/Sessions";
import { Sync } from "./panes/Sync"; import { Sync } from "./panes/Sync";
import { ThemeShop } from "./panes/ThemeShop"; import { ThemeShop } from "./panes/ThemeShop";
import { isExperimentEnabled } from "../../redux/reducers/experiments";
export default function Settings() { export default function Settings() {
const history = useHistory(); const history = useHistory();
@ -126,14 +127,14 @@ export default function Settings() {
title: <Text id="app.settings.pages.experiments.title" />, title: <Text id="app.settings.pages.experiments.title" />,
}, },
{ {
divider: !isExperimentEnabled('theme_shop'), divider: !isExperimentEnabled("theme_shop"),
category: "revolt", category: "revolt",
id: "bots", id: "bots",
icon: <Bot size={20} />, icon: <Bot size={20} />,
title: <Text id="app.settings.pages.bots.title" />, title: <Text id="app.settings.pages.bots.title" />,
}, },
{ {
hidden: !isExperimentEnabled('theme_shop'), hidden: !isExperimentEnabled("theme_shop"),
divider: true, divider: true,
id: "theme_shop", id: "theme_shop",
icon: <Store size={20} />, icon: <Store size={20} />,
@ -179,9 +180,11 @@ export default function Settings() {
<Route path="/settings/bots"> <Route path="/settings/bots">
<MyBots /> <MyBots />
</Route> </Route>
{isExperimentEnabled('theme_shop') && <Route path="/settings/theme_shop"> {isExperimentEnabled("theme_shop") && (
<ThemeShop /> <Route path="/settings/theme_shop">
</Route>} <ThemeShop />
</Route>
)}
<Route path="/settings/feedback"> <Route path="/settings/feedback">
<Feedback /> <Feedback />
</Route> </Route>

View file

@ -4,6 +4,9 @@ import Button from "../../../components/ui/Button";
import Checkbox from "../../../components/ui/Checkbox"; import Checkbox from "../../../components/ui/Checkbox";
export function Native() { 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 [config, setConfig] = useState(window.native.getConfig());
const [autoStart, setAutoStart] = useState<boolean | undefined>(); const [autoStart, setAutoStart] = useState<boolean | undefined>();
const fetchValue = () => window.native.getAutoStart().then(setAutoStart); const fetchValue = () => window.native.getAutoStart().then(setAutoStart);