From e361289c061120c882c655032af1933a535e24a3 Mon Sep 17 00:00:00 2001 From: infinite-persistence Date: Tue, 2 Mar 2021 18:12:54 +0800 Subject: [PATCH] Don't close main player when editing comments https://discord.com/channels/362322208485277697/363087331475062785/815132676293918730 - Renamed `closeInlinePlayer` to `clearPlayingUri` to reflect it's actual function. - Add additional check to see if the current video is actually inline before closing it. Wanted to refactor out an actual `closeInlinePlayer`, but let's wait until there are more usages. --- ui/component/comment/index.js | 4 +++- ui/component/comment/view.jsx | 10 +++++++--- ui/component/commentMenuList/index.js | 4 +++- ui/component/commentMenuList/view.jsx | 10 +++++++--- 4 files changed, 20 insertions(+), 8 deletions(-) diff --git a/ui/component/comment/index.js b/ui/component/comment/index.js index 950af4009..40766512e 100644 --- a/ui/component/comment/index.js +++ b/ui/component/comment/index.js @@ -7,6 +7,7 @@ import { doSetPlayingUri } from 'redux/actions/content'; import { selectUserVerifiedEmail } from 'redux/selectors/user'; import { makeSelectOthersReactionsForComment } from 'redux/selectors/comments'; import { selectActiveChannelClaim } from 'redux/selectors/app'; +import { selectPlayingUri } from 'redux/selectors/content'; import Comment from './view'; const select = (state, props) => ({ @@ -16,10 +17,11 @@ const select = (state, props) => ({ othersReacts: makeSelectOthersReactionsForComment(props.commentId)(state), activeChannelClaim: selectActiveChannelClaim(state), myChannels: selectMyChannelClaims(state), + playingUri: selectPlayingUri(state), }); const perform = (dispatch) => ({ - closeInlinePlayer: () => dispatch(doSetPlayingUri({ uri: null })), + clearPlayingUri: () => dispatch(doSetPlayingUri({ uri: null })), updateComment: (commentId, comment) => dispatch(doCommentUpdate(commentId, comment)), doToast: (options) => dispatch(doToast(options)), }); diff --git a/ui/component/comment/view.jsx b/ui/component/comment/view.jsx index 8f6c4f528..a01f44890 100644 --- a/ui/component/comment/view.jsx +++ b/ui/component/comment/view.jsx @@ -23,7 +23,7 @@ import CommentMenuList from 'component/commentMenuList'; import UriIndicator from 'component/uriIndicator'; type Props = { - closeInlinePlayer: () => void, + clearPlayingUri: () => void, uri: string, author: ?string, // LBRY Channel Name, e.g. @channel authorUri: string, // full LBRY Channel URI: lbry://@channel#123... @@ -48,6 +48,7 @@ type Props = { }, commentIdentityChannel: any, activeChannelClaim: ?ChannelClaim, + playingUri: ?PlayingUri, }; const LENGTH_TO_COLLAPSE = 300; @@ -55,7 +56,7 @@ const ESCAPE_KEY = 27; function Comment(props: Props) { const { - closeInlinePlayer, + clearPlayingUri, uri, author, authorUri, @@ -73,6 +74,7 @@ function Comment(props: Props) { threadDepth, isPinned, othersReacts, + playingUri, } = props; const { push, @@ -126,7 +128,9 @@ function Comment(props: Props) { } function handleEditComment() { - closeInlinePlayer(); + if (playingUri && playingUri.source === 'comment') { + clearPlayingUri(); + } setEditing(true); } diff --git a/ui/component/commentMenuList/index.js b/ui/component/commentMenuList/index.js index 055d7d868..858bc800d 100644 --- a/ui/component/commentMenuList/index.js +++ b/ui/component/commentMenuList/index.js @@ -5,6 +5,7 @@ import { doToggleMuteChannel } from 'redux/actions/blocked'; // import { doSetActiveChannel } from 'redux/actions/app'; import { doSetPlayingUri } from 'redux/actions/content'; import { selectActiveChannelClaim } from 'redux/selectors/app'; +import { selectPlayingUri } from 'redux/selectors/content'; import CommentMenuList from './view'; const select = (state, props) => ({ @@ -12,10 +13,11 @@ const select = (state, props) => ({ claimIsMine: makeSelectClaimIsMine(props.uri)(state), contentChannelPermanentUrl: makeSelectChannelPermUrlForClaimUri(props.uri)(state), activeChannelClaim: selectActiveChannelClaim(state), + playingUri: selectPlayingUri(state), }); const perform = (dispatch) => ({ - closeInlinePlayer: () => dispatch(doSetPlayingUri({ uri: null })), + clearPlayingUri: () => dispatch(doSetPlayingUri({ uri: null })), deleteComment: (commentId, creatorChannelUrl) => dispatch(doCommentAbandon(commentId, creatorChannelUrl)), blockChannel: (channelUri) => dispatch(doToggleMuteChannel(channelUri)), pinComment: (commentId, remove) => dispatch(doCommentPin(commentId, remove)), diff --git a/ui/component/commentMenuList/view.jsx b/ui/component/commentMenuList/view.jsx index 843289a49..65af155d9 100644 --- a/ui/component/commentMenuList/view.jsx +++ b/ui/component/commentMenuList/view.jsx @@ -7,7 +7,7 @@ import Icon from 'component/common/icon'; type Props = { uri: string, - closeInlinePlayer: () => void, + clearPlayingUri: () => void, authorUri: string, // full LBRY Channel URI: lbry://@channel#123... commentId: string, // sha256 digest identifying the comment claimIsMine: boolean, // if you control the claim which this comment was posted on @@ -24,6 +24,7 @@ type Props = { claimIsMine: boolean, isTopLevel: boolean, commentModBlock: (string) => void, + playingUri: ?PlayingUri, }; function CommentMenuList(props: Props) { @@ -36,7 +37,7 @@ function CommentMenuList(props: Props) { blockChannel, pinComment, claimIsMine, - closeInlinePlayer, + clearPlayingUri, activeChannelClaim, contentChannelPermanentUrl, isTopLevel, @@ -44,6 +45,7 @@ function CommentMenuList(props: Props) { handleEditComment, fetchComments, commentModBlock, + playingUri, } = props; const activeChannelIsCreator = activeChannelClaim && activeChannelClaim.permanent_url === contentChannelPermanentUrl; @@ -52,7 +54,9 @@ function CommentMenuList(props: Props) { } function handleDeleteComment() { - closeInlinePlayer(); + if (playingUri && playingUri.source === 'comment') { + clearPlayingUri(); + } deleteComment(commentId, commentIsMine ? undefined : contentChannelPermanentUrl); }