mirror of
https://github.com/revoltchat/revite.git
synced 2024-11-25 16:40:58 -05:00
Make theme shop hidden an experiment
This commit is contained in:
parent
d7f08449cb
commit
068540d366
4 changed files with 27 additions and 7 deletions
|
@ -50,6 +50,7 @@ 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();
|
||||||
|
@ -125,12 +126,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'),
|
||||||
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'),
|
||||||
divider: true,
|
divider: true,
|
||||||
id: "theme_shop",
|
id: "theme_shop",
|
||||||
icon: <Store size={20} />,
|
icon: <Store size={20} />,
|
||||||
|
@ -176,9 +179,9 @@ export default function Settings() {
|
||||||
<Route path="/settings/bots">
|
<Route path="/settings/bots">
|
||||||
<MyBots />
|
<MyBots />
|
||||||
</Route>
|
</Route>
|
||||||
<Route path="/settings/theme_shop">
|
{isExperimentEnabled('theme_shop') && <Route path="/settings/theme_shop">
|
||||||
<ThemeShop />
|
<ThemeShop />
|
||||||
</Route>
|
</Route>}
|
||||||
<Route path="/settings/feedback">
|
<Route path="/settings/feedback">
|
||||||
<Feedback />
|
<Feedback />
|
||||||
</Route>
|
</Route>
|
||||||
|
|
|
@ -47,6 +47,7 @@ import notoSVG from "../assets/noto_emoji.svg";
|
||||||
import openmojiSVG from "../assets/openmoji_emoji.svg";
|
import openmojiSVG from "../assets/openmoji_emoji.svg";
|
||||||
import twemojiSVG from "../assets/twemoji_emoji.svg";
|
import twemojiSVG from "../assets/twemoji_emoji.svg";
|
||||||
import { Link } from "react-router-dom";
|
import { Link } from "react-router-dom";
|
||||||
|
import { isExperimentEnabled } from "../../../redux/reducers/experiments";
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
settings: Settings;
|
settings: Settings;
|
||||||
|
@ -137,11 +138,11 @@ export function Component(props: Props) {
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<Link to="/settings/theme_shop">
|
{isExperimentEnabled('theme_shop') && <Link to="/settings/theme_shop">
|
||||||
<CategoryButton icon={<Store size={24} />} action="chevron" hover>
|
<CategoryButton icon={<Store size={24} />} action="chevron" hover>
|
||||||
<Text id="app.settings.pages.theme_shop.title" />
|
<Text id="app.settings.pages.theme_shop.title" />
|
||||||
</CategoryButton>
|
</CategoryButton>
|
||||||
</Link>
|
</Link>}
|
||||||
|
|
||||||
<h3>
|
<h3>
|
||||||
<Text id="app.settings.pages.appearance.accent_selector" />
|
<Text id="app.settings.pages.appearance.accent_selector" />
|
||||||
|
|
|
@ -7,6 +7,7 @@ import {
|
||||||
AVAILABLE_EXPERIMENTS,
|
AVAILABLE_EXPERIMENTS,
|
||||||
ExperimentOptions,
|
ExperimentOptions,
|
||||||
EXPERIMENTS,
|
EXPERIMENTS,
|
||||||
|
isExperimentEnabled,
|
||||||
} from "../../../redux/reducers/experiments";
|
} from "../../../redux/reducers/experiments";
|
||||||
|
|
||||||
import Checkbox from "../../../components/ui/Checkbox";
|
import Checkbox from "../../../components/ui/Checkbox";
|
||||||
|
@ -24,7 +25,7 @@ export function Component(props: Props) {
|
||||||
{AVAILABLE_EXPERIMENTS.map((key) => (
|
{AVAILABLE_EXPERIMENTS.map((key) => (
|
||||||
<Checkbox
|
<Checkbox
|
||||||
key={key}
|
key={key}
|
||||||
checked={(props.options?.enabled ?? []).indexOf(key) > -1}
|
checked={isExperimentEnabled(key, props.options)}
|
||||||
onChange={(enabled) =>
|
onChange={(enabled) =>
|
||||||
dispatch({
|
dispatch({
|
||||||
type: enabled
|
type: enabled
|
||||||
|
|
|
@ -1,5 +1,9 @@
|
||||||
export type Experiments = "search";
|
import { getState } from "..";
|
||||||
export const AVAILABLE_EXPERIMENTS: Experiments[] = [];
|
|
||||||
|
export type Experiments = "search" | "theme_shop";
|
||||||
|
|
||||||
|
export const AVAILABLE_EXPERIMENTS: Experiments[] = ["theme_shop"];
|
||||||
|
|
||||||
export const EXPERIMENTS: {
|
export const EXPERIMENTS: {
|
||||||
[key in Experiments]: { title: string; description: string };
|
[key in Experiments]: { title: string; description: string };
|
||||||
} = {
|
} = {
|
||||||
|
@ -7,6 +11,10 @@ export const EXPERIMENTS: {
|
||||||
title: "Search",
|
title: "Search",
|
||||||
description: "Allows you to search for messages in channels.",
|
description: "Allows you to search for messages in channels.",
|
||||||
},
|
},
|
||||||
|
theme_shop: {
|
||||||
|
title: "Theme Shop",
|
||||||
|
description: "Allows you to access and set user submitted themes.",
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
export interface ExperimentOptions {
|
export interface ExperimentOptions {
|
||||||
|
@ -50,3 +58,10 @@ export function experiments(
|
||||||
return state;
|
return state;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function isExperimentEnabled(
|
||||||
|
name: Experiments,
|
||||||
|
experiments: ExperimentOptions = getState().experiments,
|
||||||
|
) {
|
||||||
|
return experiments.enabled?.includes(name) ?? false;
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue