diff --git a/src/components/settings/appearance/AppearanceOptions.tsx b/src/components/settings/appearance/AppearanceOptions.tsx index ef70781f..b3951813 100644 --- a/src/components/settings/appearance/AppearanceOptions.tsx +++ b/src/components/settings/appearance/AppearanceOptions.tsx @@ -40,6 +40,20 @@ export default function AppearanceOptions() { } /> + {/* Option to prevent being shown age gate. */} + + settings.get("appearance:bypass_age_gate") ?? false + } + onChange={(v) => settings.set("appearance:bypass_age_gate", v)} + title={ + + } + description={ + + } + />

diff --git a/src/mobx/stores/Settings.ts b/src/mobx/stores/Settings.ts index bfb28cf4..d9e4edb8 100644 --- a/src/mobx/stores/Settings.ts +++ b/src/mobx/stores/Settings.ts @@ -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; @@ -37,8 +38,7 @@ export interface ISettings { * Manages user settings. */ export default class Settings - implements Store, Persistent, Syncable -{ + implements Store, Persistent, Syncable { private data: ObservableMap; theme: STheme; diff --git a/src/pages/channels/Channel.tsx b/src/pages/channels/Channel.tsx index 3545fd55..f3dc6d6c 100644 --- a/src/pages/channels/Channel.tsx +++ b/src/pages/channels/Channel.tsx @@ -180,13 +180,7 @@ const TextChannel = observer(({ channel }: { channel: ChannelI }) => { + gated={ShowAgeGate({ channel })}> @@ -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 ( <>