comments cleanup

This commit is contained in:
Jessop Breth 2019-06-24 23:27:18 -04:00 committed by Sean Yesmunt
parent 99c85a2ff7
commit 97ba09b605
8 changed files with 74 additions and 62 deletions

View file

@ -3,8 +3,7 @@ import React from 'react';
import { FormField, Form } from 'component/common/form';
import Button from 'component/button';
import ChannelSection from 'component/selectChannel';
import { COMMENT_ACKNOWLEDGED, COMMENT_ACKNOWLEDGED_TRUE } from 'constants/settings';
import { usePersistedState } from 'util/use-persisted-state';
import usePersistedState from 'util/use-persisted-state';
// props:
type Props = {
@ -14,10 +13,11 @@ type Props = {
};
export function CommentCreate(props: Props) {
const COMMENT_ACKNOWLEDGED = 'COMMENT_ACKNOWLEDGED';
const { createComment, claim } = props;
const { claim_id: claimId } = claim;
const [commentValue, setCommentValue] = usePersistedState(`comment-${claimId}`, '');
const [commentAck, setCommentAck] = usePersistedState(COMMENT_ACKNOWLEDGED, 'no');
const [commentAck, setCommentAck] = usePersistedState(COMMENT_ACKNOWLEDGED, false);
const [channel, setChannel] = usePersistedState('COMMENT_CHANNEL', 'anonymous');
function handleCommentChange(event) {
@ -29,7 +29,7 @@ export function CommentCreate(props: Props) {
}
function handleCommentAck(event) {
setCommentAck(COMMENT_ACKNOWLEDGED_TRUE);
setCommentAck(true);
}
function handleSubmit() {
if (channel !== 'new' && commentValue.length) createComment(commentValue, claimId, channel);
@ -38,7 +38,7 @@ export function CommentCreate(props: Props) {
return (
<React.Fragment>
{commentAck !== COMMENT_ACKNOWLEDGED_TRUE && (
{commentAck !== true && (
<section className="card card--section">
<div className="card__content">
<div className="media__title">About comments..</div>
@ -51,7 +51,7 @@ export function CommentCreate(props: Props) {
</div>
</section>
)}
{commentAck === COMMENT_ACKNOWLEDGED_TRUE && (
{commentAck === true && (
<section className="card card--section">
<Form onSubmit={handleSubmit}>
<div className="card__content">

View file

@ -4,12 +4,9 @@ import {
makeSelectContentTypeForUri,
makeSelectMetadataForUri,
makeSelectFileInfoForUri,
doToast,
} from 'lbry-redux';
import { selectUser } from 'lbryinc';
import { doOpenFileInFolder } from 'redux/actions/file';
import { selectHasClickedComment } from 'redux/selectors/app';
import { doClickCommentButton } from 'redux/actions/app';
import FileDetails from './view';
const select = (state, props) => ({
@ -17,14 +14,11 @@ const select = (state, props) => ({
contentType: makeSelectContentTypeForUri(props.uri)(state),
fileInfo: makeSelectFileInfoForUri(props.uri)(state),
metadata: makeSelectMetadataForUri(props.uri)(state),
hasClickedComment: selectHasClickedComment(state),
user: selectUser(state),
});
const perform = dispatch => ({
openFolder: path => dispatch(doOpenFileInFolder(path)),
showSnackBar: message => dispatch(doToast({ message })),
clickCommentButton: () => dispatch(doClickCommentButton()),
});
export default connect(

View file

@ -1,6 +1,5 @@
// @flow
import React, { Fragment, PureComponent } from 'react';
import { Lbryio } from 'lbryinc';
import MarkdownPreview from 'component/common/markdown-preview';
import Button from 'component/button';
import Expandable from 'component/expandable';
@ -12,31 +11,10 @@ type Props = {
metadata: StreamMetadata,
openFolder: string => void,
contentType: string,
clickCommentButton: () => void,
showSnackBar: React$Node => void,
hasClickedComment: boolean,
user: ?any,
};
class FileDetails extends PureComponent<Props> {
constructor() {
super();
(this: any).handleCommentClick = this.handleCommentClick.bind(this);
}
handleCommentClick() {
const { clickCommentButton, showSnackBar } = this.props;
clickCommentButton();
Lbryio.call('user_tag', 'edit', { add: 'comments-waitlist' });
showSnackBar(
<span>
{__('Your Comment Has Been Posted')}
<sup>TM</sup>
</span>
);
}
render() {
const { claim, contentType, fileInfo, metadata, openFolder } = this.props;

View file

@ -1,43 +1,57 @@
// @flow
import { remote } from 'electron';
import React, { Suspense } from 'react';
import React from 'react';
import LoadingScreen from 'component/common/loading-screen';
import VideoViewer from 'component/viewers/videoViewer';
const AudioViewer = React.lazy<*>(() =>
import(/* webpackChunkName: "audioViewer" */
'component/viewers/audioViewer')
import(
/* webpackChunkName: "audioViewer" */
'component/viewers/audioViewer'
)
);
const DocumentViewer = React.lazy<*>(() =>
import(/* webpackChunkName: "documentViewer" */
'component/viewers/documentViewer')
import(
/* webpackChunkName: "documentViewer" */
'component/viewers/documentViewer'
)
);
const DocxViewer = React.lazy<*>(() =>
import(/* webpackChunkName: "docxViewer" */
'component/viewers/docxViewer')
import(
/* webpackChunkName: "docxViewer" */
'component/viewers/docxViewer'
)
);
const HtmlViewer = React.lazy<*>(() =>
import(/* webpackChunkName: "htmlViewer" */
'component/viewers/htmlViewer')
import(
/* webpackChunkName: "htmlViewer" */
'component/viewers/htmlViewer'
)
);
const PdfViewer = React.lazy<*>(() =>
import(/* webpackChunkName: "pdfViewer" */
'component/viewers/pdfViewer')
import(
/* webpackChunkName: "pdfViewer" */
'component/viewers/pdfViewer'
)
);
// @if TARGET='app'
const ComicBookViewer = React.lazy<*>(() =>
import(/* webpackChunkName: "comicBookViewer" */
'component/viewers/comicBookViewer')
import(
/* webpackChunkName: "comicBookViewer" */
'component/viewers/comicBookViewer'
)
);
const ThreeViewer = React.lazy<*>(() =>
import(/* webpackChunkName: "threeViewer" */
'component/viewers/threeViewer')
import(
/* webpackChunkName: "threeViewer" */
'component/viewers/threeViewer'
)
);
// @endif
@ -174,7 +188,7 @@ class FileRender extends React.PureComponent<Props> {
// @if TARGET='web'
// temp workaround to disabled paid content on web
if (claim && claim.value.fee && claim.value.fee.amount > 0) {
if (claim && claim.value.fee && Number(claim.value.fee.amount) > 0) {
const paidMessage = __(
'Currently, only free content is available on lbry.tv. Try viewing it in the desktop app.'
);

View file

@ -1,10 +1,12 @@
// @flow
import React, { Suspense } from 'react';
import React from 'react';
import { stopContextMenu } from 'util/context-menu';
import analytics from 'analytics';
import(/* webpackChunkName: "videojs" */
/* webpackPreload: true */
'video.js/dist/video-js.css');
import(
/* webpackChunkName: "videojs" */
/* webpackPreload: true */
'video.js/dist/video-js.css'
);
type Props = {
source: {
@ -23,7 +25,7 @@ class AudioVideoViewer extends React.PureComponent<Props> {
componentDidMount() {
const { contentType, poster, claim } = this.props;
const { name, claim_id: claimId, txid, nout } = claim;
// Quick fix to get file view events on lbry.tv
// Will need to be changed to include time to start
analytics.apiLogView(`${name}#${claimId}`, `${txid}:${nout}`, claimId);
@ -44,10 +46,12 @@ class AudioVideoViewer extends React.PureComponent<Props> {
sources,
};
import(/* webpackChunkName: "videojs" */
/* webpackMode: "lazy" */
/* webpackPreload: true */
'video.js').then(videojs => {
import(
/* webpackChunkName: "videojs" */
/* webpackMode: "lazy" */
/* webpackPreload: true */
'video.js'
).then(videojs => {
if (videojs.__esModule) {
videojs = videojs.default;
this.player = videojs(this.videoNode, videoJsOptions, () => {});

View file

@ -16,5 +16,3 @@ export const AUTOPLAY = 'autoplay';
export const RESULT_COUNT = 'resultCount';
export const OS_NOTIFICATIONS_ENABLED = 'osNotificationsEnabled';
export const AUTO_DOWNLOAD = 'autoDownload';
export const COMMENT_ACKNOWLEDGED = 'comment_acknowledged';
export const COMMENT_ACKNOWLEDGED_TRUE = 'comment_acknowledged_true';

View file

@ -23,7 +23,6 @@ export const selectUpdateUrl = createSelector(
}
);
// HERE
export const selectHasClickedComment = createSelector(
selectState,
state => state.hasClickedComment

View file

@ -285,7 +285,32 @@
"Downloading stream... not long left now!": "Downloading stream... not long left now!",
"Downloading: ": "Downloading: ",
"% complete": "% complete",
<<<<<<< HEAD
"Updates published": "Updates published",
"Your updates have been published to LBRY at the address": "Your updates have been published to LBRY at the address",
"The updates will take a few minutes to appear for other LBRY users. Until then your file will be listed as \"pending\" under your published files.": "The updates will take a few minutes to appear for other LBRY users. Until then your file will be listed as \"pending\" under your published files."
}
=======
"Incompatible Daemon": "Incompatible Daemon",
"Incompatible daemon running": "Incompatible daemon running",
"Close App and LBRY Processes": "Close App and LBRY Processes",
"Continue Anyway": "Continue Anyway",
"This app is running with an incompatible version of the LBRY protocol. You can still use it, but there may be issues. Re-run the installation package for best results.": "This app is running with an incompatible version of the LBRY protocol. You can still use it, but there may be issues. Re-run the installation package for best results.",
"Update ready to install": "Update ready to install",
"Install now": "Install now",
"Upgrade available": "Upgrade available",
"LBRY Leveled Up": "LBRY Leveled Up",
"Upgrade": "Upgrade",
"Skip": "Skip",
"An updated version of LBRY is now available.": "An updated version of LBRY is now available.",
"Your version is out of date and may be unreliable or insecure.": "Your version is out of date and may be unreliable or insecure.",
"Want to know what has changed?": "Want to know what has changed?",
"release notes": "release notes",
"Your comment": "Your comment",
"Post": "Post",
"Uh oh. The flux in our Retro Encabulator must be out of whack. Try refreshing to fix it.": "Uh oh. The flux in our Retro Encabulator must be out of whack. Try refreshing to fix it.",
"If you still have issues, your anti-virus software or firewall may be preventing startup.": "If you still have issues, your anti-virus software or firewall may be preventing startup.",
"Reach out to hello@lbry.com for help, or check out": "Reach out to hello@lbry.com for help, or check out",
"Got it!": "Got it!"
}
>>>>>>> comments cleanup