From e206395079a451a34f7752ad537d40bd21adddae Mon Sep 17 00:00:00 2001 From: marcy <69540471+reeesespuffs@users.noreply.github.com> Date: Sat, 30 Aug 2025 20:03:05 -0400 Subject: [PATCH 1/3] fix: AgeGate unreadable in darkmode & add revite's geoblock feature Signed-off-by: marcy <69540471+reeesespuffs@users.noreply.github.com> --- .../client/src/interface/channels/AgeGate.tsx | 80 +++++++++++++------ 1 file changed, 55 insertions(+), 25 deletions(-) diff --git a/packages/client/src/interface/channels/AgeGate.tsx b/packages/client/src/interface/channels/AgeGate.tsx index d9dce8de..08c1f7dc 100644 --- a/packages/client/src/interface/channels/AgeGate.tsx +++ b/packages/client/src/interface/channels/AgeGate.tsx @@ -1,14 +1,19 @@ -import { JSXElement, Match, Switch, createEffect } from "solid-js"; +import { JSXElement, Match, Switch, onMount, createSignal } from "solid-js"; import { Trans } from "@lingui-solid/solid/macro"; import { styled } from "styled-system/jsx"; import { useState } from "@revolt/state"; import { LAYOUT_SECTIONS } from "@revolt/state/stores/Layout"; -import { Button, Checkbox, iconSize } from "@revolt/ui"; +import { Button, Checkbox, iconSize, Text } from "@revolt/ui"; import MdWarning from "@material-design-icons/svg/round/warning.svg?component-solid"; +type GeoBlock = { + countryCode: string; + isAgeRestrictedGeo: boolean; +}; + /** * Age gate filter for any content */ @@ -21,21 +26,55 @@ export function AgeGate(props: { }) { const state = useState(); - const confirmed = state.layout.getSectionState(LAYOUT_SECTIONS.MATURE, false); - const allowed = state.layout.getSectionState( + const confirmed = () => state.layout.getSectionState(LAYOUT_SECTIONS.MATURE, false); + const allowed = () => state.layout.getSectionState( props.contentId + "-nsfw", false, ); + const [geoBlock, setGeoBlock] = createSignal(null); + + onMount(() => { + fetch("https://geo.revolt.chat") + .then((res) => res.json()) + .then((data) => setGeoBlock(data)) + .catch(() => setGeoBlock(null)); + }); + return ( - + + + + + {props.contentName} + + + + {geoBlock()!.countryCode === "GB" ? ( + + This channel is not available in your region while we review options on legalcompliance. + + ) : ( + This content is not available in your region. + )} + + + + + + - {props.contentName} - + + {props.contentName} + + + This channel is marked as mature. - + - - I confirm that I am at least 18 years old. + + I confirm that I am at least 18 years old. + - - - - - - - - {props.contentName} - - - - This channel is marked as mature. - - - - - state.layout.toggleSectionState(LAYOUT_SECTIONS.MATURE, false) - } - /> + }> + + + + + + {props.contentName} + + - I confirm that I am at least 18 years old. + {geoQuery.data?.countryCode == "GB" ? ( + + This channel is not available in your region while we review options on legalcompliance. + + ) : ( + This content is not available in your region. + )} - - - - - - - + + + + + + + {props.contentName} + + + + This channel is marked as mature. + + + + + state.layout.toggleSectionState(LAYOUT_SECTIONS.MATURE, false) + } + /> + + I confirm that I am at least 18 years old. + + + + + + + + + + + ); } From b65d95633ebf2ee65dbc5010d59c1466481b452b Mon Sep 17 00:00:00 2001 From: izzy Date: Fri, 5 Sep 2025 20:34:22 +0200 Subject: [PATCH 3/3] chore: format AgeGate.tsx, add space to 'legalcompliance' --- .../client/src/interface/channels/AgeGate.tsx | 37 ++++++++++--------- 1 file changed, 20 insertions(+), 17 deletions(-) diff --git a/packages/client/src/interface/channels/AgeGate.tsx b/packages/client/src/interface/channels/AgeGate.tsx index 0c335223..077f4e37 100644 --- a/packages/client/src/interface/channels/AgeGate.tsx +++ b/packages/client/src/interface/channels/AgeGate.tsx @@ -1,12 +1,12 @@ -import { JSXElement, Match, Switch, Suspense} from "solid-js"; +import { JSXElement, Match, Suspense, Switch } from "solid-js"; import { Trans } from "@lingui-solid/solid/macro"; +import { useQuery } from "@tanstack/solid-query"; import { styled } from "styled-system/jsx"; -import { useQuery } from "@tanstack/solid-query"; import { useState } from "@revolt/state"; import { LAYOUT_SECTIONS } from "@revolt/state/stores/Layout"; -import { Button, Checkbox, iconSize, Text, CircularProgress } from "@revolt/ui"; +import { Button, Checkbox, CircularProgress, Text, iconSize } from "@revolt/ui"; import MdWarning from "@material-design-icons/svg/round/warning.svg?component-solid"; @@ -27,11 +27,10 @@ export function AgeGate(props: { }) { const state = useState(); - const confirmed = () => state.layout.getSectionState(LAYOUT_SECTIONS.MATURE, false); - const allowed = () => state.layout.getSectionState( - props.contentId + "-nsfw", - false, - ); + const confirmed = () => + state.layout.getSectionState(LAYOUT_SECTIONS.MATURE, false); + const allowed = () => + state.layout.getSectionState(props.contentId + "-nsfw", false); const geoQuery = useQuery(() => ({ queryKey: ["geoblock"], @@ -43,17 +42,20 @@ export function AgeGate(props: { return response.json(); }, staleTime: 5 * 60 * 1000, // 5 minutes - throwOnError: true + throwOnError: true, })); return ( }> - + @@ -62,9 +64,10 @@ export function AgeGate(props: { {geoQuery.data?.countryCode == "GB" ? ( - - This channel is not available in your region while we review options on legalcompliance. - + + This channel is not available in your region while we review + options on legal compliance. + ) : ( This content is not available in your region. )}