mirror of
https://github.com/LemmyNet/lemmy-ui.git
synced 2024-11-26 06:11:15 +00:00
Make confirm popup for adult consent
This commit is contained in:
parent
e48590b9d6
commit
fff198a012
5 changed files with 45 additions and 23 deletions
|
@ -1 +1 @@
|
||||||
Subproject commit b0dab329ce23cfaec4a3a034ea2fee210888922e
|
Subproject commit a94ef775f3f923067b48c1719cda206dbcf1a9e5
|
|
@ -14,6 +14,7 @@ import "./styles.scss";
|
||||||
import { Theme } from "./theme";
|
import { Theme } from "./theme";
|
||||||
import AnonymousGuard from "../common/anonymous-guard";
|
import AnonymousGuard from "../common/anonymous-guard";
|
||||||
import { destroyTippy, setupTippy } from "../../tippy";
|
import { destroyTippy, setupTippy } from "../../tippy";
|
||||||
|
import { adultConsentLocalStorageKey } from "shared/config";
|
||||||
|
|
||||||
export class App extends Component<any, any> {
|
export class App extends Component<any, any> {
|
||||||
private isoData: IsoDataOptionalSite = setIsoData(this.context);
|
private isoData: IsoDataOptionalSite = setIsoData(this.context);
|
||||||
|
@ -25,6 +26,19 @@ export class App extends Component<any, any> {
|
||||||
}
|
}
|
||||||
|
|
||||||
componentDidMount(): void {
|
componentDidMount(): void {
|
||||||
|
const siteRes = this.isoData.site_res;
|
||||||
|
|
||||||
|
if (
|
||||||
|
siteRes?.site_view.site.content_warning &&
|
||||||
|
!(siteRes?.my_user || localStorage.getItem(adultConsentLocalStorageKey))
|
||||||
|
) {
|
||||||
|
if (confirm(siteRes.site_view.site.content_warning)) {
|
||||||
|
localStorage.setItem(adultConsentLocalStorageKey, "true");
|
||||||
|
} else {
|
||||||
|
history.back();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
setupTippy(this.rootRef);
|
setupTippy(this.rootRef);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2,6 +2,8 @@ import classNames from "classnames";
|
||||||
import { Component } from "inferno";
|
import { Component } from "inferno";
|
||||||
|
|
||||||
import { UserService } from "../../services";
|
import { UserService } from "../../services";
|
||||||
|
import { setIsoData } from "@utils/app";
|
||||||
|
import { IsoDataOptionalSite } from "shared/interfaces";
|
||||||
|
|
||||||
const iconThumbnailSize = 96;
|
const iconThumbnailSize = 96;
|
||||||
const thumbnailSize = 256;
|
const thumbnailSize = 256;
|
||||||
|
@ -19,6 +21,8 @@ interface PictrsImageProps {
|
||||||
}
|
}
|
||||||
|
|
||||||
export class PictrsImage extends Component<PictrsImageProps, any> {
|
export class PictrsImage extends Component<PictrsImageProps, any> {
|
||||||
|
private isoData: IsoDataOptionalSite = setIsoData(this.context);
|
||||||
|
|
||||||
constructor(props: any, context: any) {
|
constructor(props: any, context: any) {
|
||||||
super(props, context);
|
super(props, context);
|
||||||
}
|
}
|
||||||
|
@ -26,13 +30,11 @@ export class PictrsImage extends Component<PictrsImageProps, any> {
|
||||||
render() {
|
render() {
|
||||||
const { src, icon, iconOverlay, banner, thumbnail, nsfw, pushup, cardTop } =
|
const { src, icon, iconOverlay, banner, thumbnail, nsfw, pushup, cardTop } =
|
||||||
this.props;
|
this.props;
|
||||||
let user_blur_nsfw = true;
|
|
||||||
if (UserService.Instance.myUserInfo) {
|
|
||||||
user_blur_nsfw =
|
|
||||||
UserService.Instance.myUserInfo?.local_user_view.local_user.blur_nsfw;
|
|
||||||
}
|
|
||||||
|
|
||||||
const blur_image = nsfw && user_blur_nsfw;
|
const blurImage =
|
||||||
|
nsfw &&
|
||||||
|
(!this.isoData.site_res?.site_view.site.content_warning ||
|
||||||
|
UserService.Instance.myUserInfo?.local_user_view.local_user.blur_nsfw);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<picture>
|
<picture>
|
||||||
|
@ -52,8 +54,8 @@ export class PictrsImage extends Component<PictrsImageProps, any> {
|
||||||
"img-expanded slight-radius": !(thumbnail || icon),
|
"img-expanded slight-radius": !(thumbnail || icon),
|
||||||
"img-blur": thumbnail && nsfw,
|
"img-blur": thumbnail && nsfw,
|
||||||
"object-fit-cover img-icon me-1": icon,
|
"object-fit-cover img-icon me-1": icon,
|
||||||
"img-blur-icon": icon && blur_image,
|
"img-blur-icon": icon && blurImage,
|
||||||
"img-blur-thumb": thumbnail && blur_image,
|
"img-blur-thumb": thumbnail && blurImage,
|
||||||
"ms-2 mb-0 rounded-circle object-fit-cover avatar-overlay":
|
"ms-2 mb-0 rounded-circle object-fit-cover avatar-overlay":
|
||||||
iconOverlay,
|
iconOverlay,
|
||||||
"avatar-pushup": pushup,
|
"avatar-pushup": pushup,
|
||||||
|
|
|
@ -261,6 +261,7 @@ export class Signup extends Component<
|
||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
{this.renderCaptcha()}
|
{this.renderCaptcha()}
|
||||||
|
{!this.state.siteRes.site_view.site.content_warning && (
|
||||||
<div className="mb-3 row">
|
<div className="mb-3 row">
|
||||||
<div className="col-sm-10">
|
<div className="col-sm-10">
|
||||||
<div className="form-check">
|
<div className="form-check">
|
||||||
|
@ -271,12 +272,16 @@ export class Signup extends Component<
|
||||||
checked={this.state.form.show_nsfw}
|
checked={this.state.form.show_nsfw}
|
||||||
onChange={linkEvent(this, this.handleRegisterShowNsfwChange)}
|
onChange={linkEvent(this, this.handleRegisterShowNsfwChange)}
|
||||||
/>
|
/>
|
||||||
<label className="form-check-label" htmlFor="register-show-nsfw">
|
<label
|
||||||
|
className="form-check-label"
|
||||||
|
htmlFor="register-show-nsfw"
|
||||||
|
>
|
||||||
{I18NextService.i18n.t("show_nsfw")}
|
{I18NextService.i18n.t("show_nsfw")}
|
||||||
</label>
|
</label>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
)}
|
||||||
<input
|
<input
|
||||||
tabIndex={-1}
|
tabIndex={-1}
|
||||||
autoComplete="false"
|
autoComplete="false"
|
||||||
|
|
|
@ -28,6 +28,7 @@ export const fetchLimit = 20;
|
||||||
export const relTags = "noopener nofollow";
|
export const relTags = "noopener nofollow";
|
||||||
export const emDash = "\u2014";
|
export const emDash = "\u2014";
|
||||||
export const authCookieName = "jwt";
|
export const authCookieName = "jwt";
|
||||||
|
export const adultConsentLocalStorageKey = "adult-consent";
|
||||||
|
|
||||||
// No. of max displayed communities per
|
// No. of max displayed communities per
|
||||||
// page on route "/communities"
|
// page on route "/communities"
|
||||||
|
|
Loading…
Reference in a new issue