From f01701f5ecbe6c914a6d3b3d19cfdd8a0d03636f Mon Sep 17 00:00:00 2001 From: matc-pub <161147791+matc-pub@users.noreply.github.com> Date: Mon, 22 Apr 2024 17:05:54 +0200 Subject: [PATCH] Content warning fixups (#2432) * Content warning fixups - Require consent of logged in existing users. - Prevent link clicks in blurred areas. - Enable tippy again. - Prevent stacking of countdowns for Back button. - Fix auto expand blocking for images. * Hide content warning for logged in users --- src/server/utils/create-ssr-html.tsx | 1 + src/shared/components/app/app.tsx | 9 +++++++++ src/shared/components/common/adult-consent-modal.tsx | 1 + src/shared/components/post/post-listing.tsx | 7 +++++-- 4 files changed, 16 insertions(+), 2 deletions(-) diff --git a/src/server/utils/create-ssr-html.tsx b/src/server/utils/create-ssr-html.tsx index cb0ec615..fddb5b26 100644 --- a/src/server/utils/create-ssr-html.tsx +++ b/src/server/utils/create-ssr-html.tsx @@ -105,6 +105,7 @@ export async function createSsrHtml( -moz-filter: blur(10px); -o-filter: blur(10px); -ms-filter: blur(10px); + pointer-events: none; } diff --git a/src/shared/components/app/app.tsx b/src/shared/components/app/app.tsx index 4d1cbea2..0f26250e 100644 --- a/src/shared/components/app/app.tsx +++ b/src/shared/components/app/app.tsx @@ -14,6 +14,7 @@ import "./styles.scss"; import { Theme } from "./theme"; import AnonymousGuard from "../common/anonymous-guard"; import AdultConsentModal from "../common/adult-consent-modal"; +import { destroyTippy, setupTippy } from "../../tippy"; function handleJumpToContent(event) { event.preventDefault(); @@ -23,6 +24,14 @@ export default class App extends Component { private isoData: IsoDataOptionalSite = setIsoData(this.context); private readonly rootRef = createRef(); + componentDidMount() { + setupTippy(this.rootRef); + } + + componentWillUnmount() { + destroyTippy(); + } + render() { const siteRes = this.isoData.site_res; const siteView = siteRes?.site_view; diff --git a/src/shared/components/common/adult-consent-modal.tsx b/src/shared/components/common/adult-consent-modal.tsx index ca73e895..bd46abb2 100644 --- a/src/shared/components/common/adult-consent-modal.tsx +++ b/src/shared/components/common/adult-consent-modal.tsx @@ -96,6 +96,7 @@ function handleAdultConsent(i: AdultConsentModal) { function handleAdultConsentGoBack(i: AdultConsentModal) { i.setState({ redirectCountdown: 5 }); + clearInterval(i.redirectTimeout); i.redirectTimeout = setInterval(() => { i.setState(prev => ({ ...prev, diff --git a/src/shared/components/post/post-listing.tsx b/src/shared/components/post/post-listing.tsx index a7c3b7de..f577a869 100644 --- a/src/shared/components/post/post-listing.tsx +++ b/src/shared/components/post/post-listing.tsx @@ -103,7 +103,7 @@ export class PostListing extends Component { private readonly isoData: IsoDataOptionalSite = setIsoData(this.context); state: PostListingState = { showEdit: false, - imageExpanded: !!this.isoData.site_res?.site_view.site.content_warning, + imageExpanded: false, viewSource: false, showAdvanced: false, showBody: false, @@ -135,7 +135,10 @@ export class PostListing extends Component { } componentDidMount(): void { - if (UserService.Instance.myUserInfo) { + if ( + UserService.Instance.myUserInfo && + !this.isoData.showAdultConsentModal + ) { const { auto_expand, blur_nsfw } = UserService.Instance.myUserInfo.local_user_view.local_user; this.setState({