Content warning
This commit is contained in:
@ -1,11 +1,13 @@
|
|||||||
import { useState } from "react";
|
import { useState } from "react";
|
||||||
import { useNavigate } from "react-router-dom";
|
import { useNavigate } from "react-router-dom";
|
||||||
|
|
||||||
|
export function isContentWarningAccepted() {
|
||||||
|
return Boolean(window.localStorage.getItem("accepted-content-warning"));
|
||||||
|
}
|
||||||
|
|
||||||
export function ContentWarningOverlay() {
|
export function ContentWarningOverlay() {
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
const [is18Plus, setIs18Plus] = useState(
|
const [is18Plus, setIs18Plus] = useState(isContentWarningAccepted());
|
||||||
Boolean(window.localStorage.getItem("accepted-content-warning"))
|
|
||||||
);
|
|
||||||
if (is18Plus) return null;
|
if (is18Plus) return null;
|
||||||
|
|
||||||
function grownUp() {
|
function grownUp() {
|
@ -1,5 +1,9 @@
|
|||||||
.video-tile {}
|
.video-tile {}
|
||||||
|
|
||||||
|
.video-tile.nsfw>div:nth-child(1) {
|
||||||
|
filter: blur(3px);
|
||||||
|
}
|
||||||
|
|
||||||
.video-tile>div:nth-child(1) {
|
.video-tile>div:nth-child(1) {
|
||||||
border-radius: 16px;
|
border-radius: 16px;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
|
@ -8,6 +8,7 @@ import { StreamState } from "index";
|
|||||||
import { findTag, getHost } from "utils";
|
import { findTag, getHost } from "utils";
|
||||||
import { formatSats } from "number";
|
import { formatSats } from "number";
|
||||||
import ZapStream from "../../public/zap-stream.svg";
|
import ZapStream from "../../public/zap-stream.svg";
|
||||||
|
import { isContentWarningAccepted } from "./content-warning";
|
||||||
|
|
||||||
export function VideoTile({
|
export function VideoTile({
|
||||||
ev,
|
ev,
|
||||||
@ -24,6 +25,7 @@ export function VideoTile({
|
|||||||
const image = findTag(ev, "image");
|
const image = findTag(ev, "image");
|
||||||
const status = findTag(ev, "status");
|
const status = findTag(ev, "status");
|
||||||
const viewers = findTag(ev, "current_participants");
|
const viewers = findTag(ev, "current_participants");
|
||||||
|
const contentWarning = findTag(ev, "content-warning") && !isContentWarningAccepted();
|
||||||
const host = getHost(ev);
|
const host = getHost(ev);
|
||||||
|
|
||||||
const link = encodeTLV(
|
const link = encodeTLV(
|
||||||
@ -34,7 +36,7 @@ export function VideoTile({
|
|||||||
ev.pubkey
|
ev.pubkey
|
||||||
);
|
);
|
||||||
return (
|
return (
|
||||||
<Link to={`/${link}`} className="video-tile" ref={ref}>
|
<Link to={`/${link}`} className={`video-tile${contentWarning ? " nsfw" : ""}`} ref={ref}>
|
||||||
<div
|
<div
|
||||||
style={{
|
style={{
|
||||||
backgroundImage: `url(${inView ? ((image?.length ?? 0) > 0 ? image : ZapStream) : ""})`,
|
backgroundImage: `url(${inView ? ((image?.length ?? 0) > 0 ? image : ZapStream) : ""})`,
|
||||||
|
@ -22,6 +22,7 @@ import { StreamCards } from "element/stream-cards";
|
|||||||
import { formatSats } from "number";
|
import { formatSats } from "number";
|
||||||
import { StreamTimer } from "element/stream-time";
|
import { StreamTimer } from "element/stream-time";
|
||||||
import { ShareMenu } from "element/share-menu";
|
import { ShareMenu } from "element/share-menu";
|
||||||
|
import { ContentWarningOverlay, isContentWarningAccepted } from "element/content-warning";
|
||||||
|
|
||||||
function ProfileInfo({ ev, goal }: { ev?: NostrEvent; goal?: TaggedRawEvent }) {
|
function ProfileInfo({ ev, goal }: { ev?: NostrEvent; goal?: TaggedRawEvent }) {
|
||||||
const login = useLogin();
|
const login = useLogin();
|
||||||
@ -112,8 +113,13 @@ export function StreamPage() {
|
|||||||
const summary = findTag(ev, "summary");
|
const summary = findTag(ev, "summary");
|
||||||
const image = findTag(ev, "image");
|
const image = findTag(ev, "image");
|
||||||
const stream = findTag(ev, "streaming");
|
const stream = findTag(ev, "streaming");
|
||||||
|
const contentWarning = findTag(ev, "content-warning");
|
||||||
const tags = ev?.tags.filter((a) => a[0] === "t").map((a) => a[1]) ?? [];
|
const tags = ev?.tags.filter((a) => a[0] === "t").map((a) => a[1]) ?? [];
|
||||||
|
|
||||||
|
if (contentWarning && !isContentWarningAccepted()) {
|
||||||
|
return <ContentWarningOverlay />
|
||||||
|
}
|
||||||
|
|
||||||
const descriptionContent = [
|
const descriptionContent = [
|
||||||
title,
|
title,
|
||||||
(summary?.length ?? 0) > 0 ? summary : "Nostr live streaming",
|
(summary?.length ?? 0) > 0 ? summary : "Nostr live streaming",
|
||||||
|
Reference in New Issue
Block a user