feat: Add setting to disable the nsfw channel prompt

pull/806/head
Ryan Alexander 2022-10-07 19:11:56 +10:00
parent eb4670ec43
commit 3bf0890937
No known key found for this signature in database
GPG Key ID: FB967AC8F39624BF
3 changed files with 28 additions and 9 deletions

View File

@ -40,6 +40,20 @@ export default function AppearanceOptions() {
<Text id="app.settings.pages.appearance.appearance_options.show_account_age_desc" />
}
/>
{/* Option to prevent being shown age gate. */}
<ObservedInputElement
type="checkbox"
value={() =>
settings.get("appearance:bypass_age_gate") ?? false
}
onChange={(v) => settings.set("appearance:bypass_age_gate", v)}
title={
<Text id="app.settings.pages.appearance.appearance_options.bypass_age_gate" />
}
description={
<Text id="app.settings.pages.appearance.appearance_options.bypass_age_gate_desc" />
}
/>
<hr />
<h3>
<Text id="app.settings.pages.appearance.theme_options.title" />

View File

@ -22,6 +22,7 @@ export interface ISettings {
"appearance:transparency": boolean;
"appearance:show_send_button": boolean;
"appearance:show_account_age": boolean;
"appearance:bypass_age_gate": boolean;
"appearance:theme:base": "dark" | "light";
"appearance:theme:overrides": Partial<Overrides>;
@ -37,8 +38,7 @@ export interface ISettings {
* Manages user settings.
*/
export default class Settings
implements Store, Persistent<ISettings>, Syncable
{
implements Store, Persistent<ISettings>, Syncable {
private data: ObservableMap<string, unknown>;
theme: STheme;

View File

@ -180,13 +180,7 @@ const TextChannel = observer(({ channel }: { channel: ChannelI }) => {
<AgeGate
type="channel"
channel={channel}
gated={
!!(
(channel.channel_type === "TextChannel" ||
channel.channel_type === "Group") &&
channel.nsfw
)
}>
gated={ShowAgeGate({ channel })}>
<ChannelHeader channel={channel} />
<ChannelMain>
<ErrorBoundary section="renderer">
@ -208,6 +202,17 @@ const TextChannel = observer(({ channel }: { channel: ChannelI }) => {
);
});
function ShowAgeGate({ channel }: { channel: ChannelI }) {
const settings = useApplicationState().settings;
if (settings.get("appearance:bypass_age_gate") ?? false) return false;
return !!(
(channel.channel_type === "TextChannel" ||
channel.channel_type === "Group") &&
channel.nsfw
);
}
function VoiceChannel({ channel }: { channel: ChannelI }) {
return (
<>