"Fixed NSFW content showing on filePage" #289
8 changed files with 82 additions and 20 deletions
|
@ -97,22 +97,22 @@ class FileCard extends React.PureComponent {
|
||||||
<TruncatedText lines={2}>{description}</TruncatedText>
|
<TruncatedText lines={2}>{description}</TruncatedText>
|
||||||
</div>
|
</div>
|
||||||
</Link>
|
</Link>
|
||||||
{obscureNsfw &&
|
|
||||||
this.state.hovered &&
|
|
||||||
<div className="card-overlay">
|
|
||||||
<p>
|
|
||||||
{__(
|
|
||||||
"This content is Not Safe For Work. To view adult content, please change your"
|
|
||||||
)}
|
|
||||||
{" "}
|
|
||||||
<Link
|
|
||||||
className="button-text"
|
|
||||||
onClick={() => navigate("settings")}
|
|
||||||
label={__("Settings")}
|
|
||||||
/>.
|
|
||||||
</p>
|
|
||||||
</div>}
|
|
||||||
</div>
|
</div>
|
||||||
|
{obscureNsfw &&
|
||||||
|
this.state.hovered &&
|
||||||
|
<div className="card-overlay">
|
||||||
|
<p>
|
||||||
|
{__(
|
||||||
|
"This content is Not Safe For Work. To view adult content, please change your"
|
||||||
|
)}
|
||||||
|
{" "}
|
||||||
|
<Link
|
||||||
|
className="button-text"
|
||||||
|
onClick={() => navigate("settings")}
|
||||||
|
label={__("Settings")}
|
||||||
|
/>.
|
||||||
|
</p>
|
||||||
|
</div>}
|
||||||
</section>
|
</section>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
import React from "react";
|
import React from "react";
|
||||||
import { connect } from "react-redux";
|
import { connect } from "react-redux";
|
||||||
import { doCloseModal } from "actions/app";
|
import { doCloseModal } from "actions/app";
|
||||||
|
import { doNavigate } from "actions/app";
|
||||||
import { selectCurrentModal } from "selectors/app";
|
import { selectCurrentModal } from "selectors/app";
|
||||||
import { doPurchaseUri, doLoadVideo } from "actions/content";
|
import { doPurchaseUri, doLoadVideo } from "actions/content";
|
||||||
import {
|
import {
|
||||||
|
@ -13,6 +14,7 @@ import {
|
||||||
makeSelectDownloadingForUri,
|
makeSelectDownloadingForUri,
|
||||||
} from "selectors/file_info";
|
} from "selectors/file_info";
|
||||||
import { makeSelectCostInfoForUri } from "selectors/cost_info";
|
import { makeSelectCostInfoForUri } from "selectors/cost_info";
|
||||||
|
import { selectObscureNsfw } from "selectors/app";
|
||||||
import Video from "./view";
|
import Video from "./view";
|
||||||
|
|
||||||
const makeSelect = () => {
|
const makeSelect = () => {
|
||||||
|
@ -27,6 +29,7 @@ const makeSelect = () => {
|
||||||
costInfo: selectCostInfo(state, props),
|
costInfo: selectCostInfo(state, props),
|
||||||
fileInfo: selectFileInfo(state, props),
|
fileInfo: selectFileInfo(state, props),
|
||||||
metadata: selectMetadata(state, props),
|
metadata: selectMetadata(state, props),
|
||||||
|
obscureNsfw: selectObscureNsfw(state),
|
||||||
modal: selectCurrentModal(state),
|
modal: selectCurrentModal(state),
|
||||||
isLoading: selectIsLoading(state, props),
|
isLoading: selectIsLoading(state, props),
|
||||||
isDownloading: selectIsDownloading(state, props),
|
isDownloading: selectIsDownloading(state, props),
|
||||||
|
@ -37,6 +40,7 @@ const makeSelect = () => {
|
||||||
};
|
};
|
||||||
|
|
||||||
const perform = dispatch => ({
|
const perform = dispatch => ({
|
||||||
|
navigate: (path, params) => dispatch(doNavigate(path, params)),
|
||||||
loadVideo: uri => dispatch(doLoadVideo(uri)),
|
loadVideo: uri => dispatch(doLoadVideo(uri)),
|
||||||
purchaseUri: uri => dispatch(doPurchaseUri(uri, "affirmPurchaseAndPlay")),
|
purchaseUri: uri => dispatch(doPurchaseUri(uri, "affirmPurchaseAndPlay")),
|
||||||
closeModal: () => dispatch(doCloseModal()),
|
closeModal: () => dispatch(doCloseModal()),
|
||||||
|
|
|
@ -1,13 +1,18 @@
|
||||||
import React from "react";
|
import React from "react";
|
||||||
import lbry from "lbry";
|
import lbry from "lbry";
|
||||||
import VideoPlayer from "./internal/player";
|
import VideoPlayer from "./internal/player";
|
||||||
|
import Link from "component/link";
|
||||||
|
import FileActions from "component/fileActions";
|
||||||
import VideoPlayButton from "./internal/play-button";
|
import VideoPlayButton from "./internal/play-button";
|
||||||
import LoadingScreen from "./internal/loading-screen";
|
import LoadingScreen from "./internal/loading-screen";
|
||||||
|
|
||||||
class Video extends React.PureComponent {
|
class Video extends React.PureComponent {
|
||||||
constructor(props) {
|
constructor(props) {
|
||||||
super(props);
|
super(props);
|
||||||
this.state = { isPlaying: false };
|
this.state = {
|
||||||
|
isPlaying: false,
|
||||||
|
showNsfwHelp: false,
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
startPlaying() {
|
startPlaying() {
|
||||||
|
@ -16,23 +21,46 @@ class Video extends React.PureComponent {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
handleMouseOver() {
|
||||||
|
if (
|
||||||
|
this.props.obscureNsfw &&
|
||||||
|
this.props.metadata &&
|
||||||
|
this.props.metadata.nsfw
|
||||||
|
) {
|
||||||
|
this.setState({
|
||||||
|
showNsfwHelp: true,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
handleMouseOut() {
|
||||||
|
if (this.state.showNsfwHelp) {
|
||||||
|
this.setState({
|
||||||
|
showNsfwHelp: false,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const {
|
const {
|
||||||
metadata,
|
metadata,
|
||||||
isLoading,
|
isLoading,
|
||||||
isDownloading,
|
isDownloading,
|
||||||
fileInfo,
|
fileInfo,
|
||||||
|
navigate,
|
||||||
contentType,
|
contentType,
|
||||||
} = this.props;
|
} = this.props;
|
||||||
const { isPlaying = false } = this.state;
|
const { isPlaying = false } = this.state;
|
||||||
|
|
||||||
const isReadyToPlay = fileInfo && fileInfo.written_bytes > 0;
|
const isReadyToPlay = fileInfo && fileInfo.written_bytes > 0;
|
||||||
|
const obscureNsfw = this.props.obscureNsfw && metadata && metadata.nsfw;
|
||||||
const mediaType = lbry.getMediaType(
|
const mediaType = lbry.getMediaType(
|
||||||
contentType,
|
contentType,
|
||||||
fileInfo && fileInfo.file_name
|
fileInfo && fileInfo.file_name
|
||||||
);
|
);
|
||||||
|
|
||||||
let loadStatusMessage = "";
|
let loadStatusMessage = "";
|
||||||
|
let onClick = () => navigate("/show", { uri });
|
||||||
|
|
||||||
if (fileInfo && fileInfo.completed && !fileInfo.written_bytes) {
|
if (fileInfo && fileInfo.completed && !fileInfo.written_bytes) {
|
||||||
loadStatusMessage = __(
|
loadStatusMessage = __(
|
||||||
|
@ -47,6 +75,7 @@ class Video extends React.PureComponent {
|
||||||
}
|
}
|
||||||
|
|
||||||
let klasses = [];
|
let klasses = [];
|
||||||
|
klasses.push(obscureNsfw ? "video--obscured " : "");
|
||||||
if (isLoading || isDownloading) klasses.push("video-embedded", "video");
|
if (isLoading || isDownloading) klasses.push("video-embedded", "video");
|
||||||
if (mediaType === "video") {
|
if (mediaType === "video") {
|
||||||
klasses.push("video-embedded", "video");
|
klasses.push("video-embedded", "video");
|
||||||
|
@ -59,7 +88,11 @@ class Video extends React.PureComponent {
|
||||||
const poster = metadata.thumbnail;
|
const poster = metadata.thumbnail;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={klasses.join(" ")}>
|
<div
|
||||||
|
className={klasses.join(" ")}
|
||||||
|
onMouseEnter={this.handleMouseOver.bind(this)}
|
||||||
|
onMouseLeave={this.handleMouseOut.bind(this)}
|
||||||
|
>
|
||||||
{isPlaying &&
|
{isPlaying &&
|
||||||
(!isReadyToPlay
|
(!isReadyToPlay
|
||||||
? <LoadingScreen status={loadStatusMessage} />
|
? <LoadingScreen status={loadStatusMessage} />
|
||||||
|
@ -81,6 +114,20 @@ class Video extends React.PureComponent {
|
||||||
mediaType={mediaType}
|
mediaType={mediaType}
|
||||||
/>
|
/>
|
||||||
</div>}
|
</div>}
|
||||||
|
{this.state.showNsfwHelp &&
|
||||||
|
<div className="card-overlay">
|
||||||
|
<p>
|
||||||
|
{__(
|
||||||
|
"This content is Not Safe For Work. To view adult content, please change your"
|
||||||
|
)}
|
||||||
|
{" "}
|
||||||
|
<Link
|
||||||
|
className="button-text"
|
||||||
|
onClick={() => navigate("/settings")}
|
||||||
|
label={__("Settings")}
|
||||||
|
/>.
|
||||||
|
</p>
|
||||||
|
</div>}
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -321,9 +321,11 @@ lbry.getMediaType = function(contentType, fileName) {
|
||||||
var ext = fileName.substr(dotIndex + 1);
|
var ext = fileName.substr(dotIndex + 1);
|
||||||
if (/^mp4|m4v|mov|webm|flv|f4v|ogv$/i.test(ext)) {
|
if (/^mp4|m4v|mov|webm|flv|f4v|ogv$/i.test(ext)) {
|
||||||
return "video";
|
return "video";
|
||||||
} else if (/^mp3|m4a|aac|wav|flac|ogg|opus$/i.test(ext)) {
|
} else if (/^mp3|m4a|aac|wav|flac|ogg|opus$/i.test(ext)) {
|
||||||
return "audio";
|
return "audio";
|
||||||
} else if (/^html|htm|xml|pdf|odf|doc|docx|md|markdown|txt|org$/i.test(ext)) {
|
} else if (
|
||||||
|
/^html|htm|xml|pdf|odf|doc|docx|md|markdown|txt|epub|org$/i.test(ext)
|
||||||
|
) {
|
||||||
return "document";
|
return "document";
|
||||||
} else {
|
} else {
|
||||||
return "unknown";
|
return "unknown";
|
||||||
|
|
|
@ -10,6 +10,7 @@ import {
|
||||||
makeSelectMetadataForUri,
|
makeSelectMetadataForUri,
|
||||||
} from "selectors/claims";
|
} from "selectors/claims";
|
||||||
import { makeSelectCostInfoForUri } from "selectors/cost_info";
|
import { makeSelectCostInfoForUri } from "selectors/cost_info";
|
||||||
|
import { selectObscureNsfw } from "selectors/app";
|
||||||
import FilePage from "./view";
|
import FilePage from "./view";
|
||||||
|
|
||||||
const makeSelect = () => {
|
const makeSelect = () => {
|
||||||
|
@ -24,6 +25,7 @@ const makeSelect = () => {
|
||||||
contentType: selectContentType(state, props),
|
contentType: selectContentType(state, props),
|
||||||
costInfo: selectCostInfo(state, props),
|
costInfo: selectCostInfo(state, props),
|
||||||
metadata: selectMetadata(state, props),
|
metadata: selectMetadata(state, props),
|
||||||
|
obscureNsfw: selectObscureNsfw(state),
|
||||||
fileInfo: selectFileInfo(state, props),
|
fileInfo: selectFileInfo(state, props),
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -81,6 +81,7 @@ class FilePage extends React.PureComponent {
|
||||||
const uriIndicator = <UriIndicator uri={uri} />;
|
const uriIndicator = <UriIndicator uri={uri} />;
|
||||||
const mediaType = lbry.getMediaType(contentType);
|
const mediaType = lbry.getMediaType(contentType);
|
||||||
const player = require("render-media");
|
const player = require("render-media");
|
||||||
|
const obscureNsfw = this.props.obscureNsfw && metadata && metadata.nsfw;
|
||||||
const isPlayable =
|
const isPlayable =
|
||||||
Object.values(player.mime).indexOf(contentType) !== -1 ||
|
Object.values(player.mime).indexOf(contentType) !== -1 ||
|
||||||
mediaType === "audio";
|
mediaType === "audio";
|
||||||
|
@ -94,7 +95,7 @@ class FilePage extends React.PureComponent {
|
||||||
? <Thumbnail src={metadata.thumbnail} />
|
? <Thumbnail src={metadata.thumbnail} />
|
||||||
: <Thumbnail />}
|
: <Thumbnail />}
|
||||||
</section>
|
</section>
|
||||||
<section className="card">
|
<section className={"card " + (obscureNsfw ? "card--obscured " : "")}>
|
||||||
<div className="card__inner">
|
<div className="card__inner">
|
||||||
<div className="card__title-identity">
|
<div className="card__title-identity">
|
||||||
{!fileInfo || fileInfo.written_bytes <= 0
|
{!fileInfo || fileInfo.written_bytes <= 0
|
||||||
|
|
|
@ -40,6 +40,7 @@ $box-shadow-focus: 2px 4px 4px 0 rgba(0,0,0,.14),2px 5px 3px -2px rgba(0,0,0,.2)
|
||||||
$transition-standard: .225s ease;
|
$transition-standard: .225s ease;
|
||||||
|
|
||||||
$blur-intensity: 8px;
|
$blur-intensity: 8px;
|
||||||
|
$blur-intensity-video: 20px;
|
||||||
|
|
||||||
@mixin clearfix()
|
@mixin clearfix()
|
||||||
{
|
{
|
||||||
|
|
|
@ -33,6 +33,11 @@ video {
|
||||||
transform: translateY(-50%);
|
transform: translateY(-50%);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
.video--obscured .video__cover
|
||||||
|
{
|
||||||
|
position: relative;
|
||||||
|
filter: blur($blur-intensity-video);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
.video__loading-screen {
|
.video__loading-screen {
|
||||||
|
|
Loading…
Reference in a new issue