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.
This commit is contained in:
infinite-persistence 2021-03-02 18:12:54 +08:00 committed by Sean Yesmunt
parent 7521ac53a3
commit e361289c06
4 changed files with 20 additions and 8 deletions

View file

@ -7,6 +7,7 @@ import { doSetPlayingUri } from 'redux/actions/content';
import { selectUserVerifiedEmail } from 'redux/selectors/user'; import { selectUserVerifiedEmail } from 'redux/selectors/user';
import { makeSelectOthersReactionsForComment } from 'redux/selectors/comments'; import { makeSelectOthersReactionsForComment } from 'redux/selectors/comments';
import { selectActiveChannelClaim } from 'redux/selectors/app'; import { selectActiveChannelClaim } from 'redux/selectors/app';
import { selectPlayingUri } from 'redux/selectors/content';
import Comment from './view'; import Comment from './view';
const select = (state, props) => ({ const select = (state, props) => ({
@ -16,10 +17,11 @@ const select = (state, props) => ({
othersReacts: makeSelectOthersReactionsForComment(props.commentId)(state), othersReacts: makeSelectOthersReactionsForComment(props.commentId)(state),
activeChannelClaim: selectActiveChannelClaim(state), activeChannelClaim: selectActiveChannelClaim(state),
myChannels: selectMyChannelClaims(state), myChannels: selectMyChannelClaims(state),
playingUri: selectPlayingUri(state),
}); });
const perform = (dispatch) => ({ const perform = (dispatch) => ({
closeInlinePlayer: () => dispatch(doSetPlayingUri({ uri: null })), clearPlayingUri: () => dispatch(doSetPlayingUri({ uri: null })),
updateComment: (commentId, comment) => dispatch(doCommentUpdate(commentId, comment)), updateComment: (commentId, comment) => dispatch(doCommentUpdate(commentId, comment)),
doToast: (options) => dispatch(doToast(options)), doToast: (options) => dispatch(doToast(options)),
}); });

View file

@ -23,7 +23,7 @@ import CommentMenuList from 'component/commentMenuList';
import UriIndicator from 'component/uriIndicator'; import UriIndicator from 'component/uriIndicator';
type Props = { type Props = {
closeInlinePlayer: () => void, clearPlayingUri: () => void,
uri: string, uri: string,
author: ?string, // LBRY Channel Name, e.g. @channel author: ?string, // LBRY Channel Name, e.g. @channel
authorUri: string, // full LBRY Channel URI: lbry://@channel#123... authorUri: string, // full LBRY Channel URI: lbry://@channel#123...
@ -48,6 +48,7 @@ type Props = {
}, },
commentIdentityChannel: any, commentIdentityChannel: any,
activeChannelClaim: ?ChannelClaim, activeChannelClaim: ?ChannelClaim,
playingUri: ?PlayingUri,
}; };
const LENGTH_TO_COLLAPSE = 300; const LENGTH_TO_COLLAPSE = 300;
@ -55,7 +56,7 @@ const ESCAPE_KEY = 27;
function Comment(props: Props) { function Comment(props: Props) {
const { const {
closeInlinePlayer, clearPlayingUri,
uri, uri,
author, author,
authorUri, authorUri,
@ -73,6 +74,7 @@ function Comment(props: Props) {
threadDepth, threadDepth,
isPinned, isPinned,
othersReacts, othersReacts,
playingUri,
} = props; } = props;
const { const {
push, push,
@ -126,7 +128,9 @@ function Comment(props: Props) {
} }
function handleEditComment() { function handleEditComment() {
closeInlinePlayer(); if (playingUri && playingUri.source === 'comment') {
clearPlayingUri();
}
setEditing(true); setEditing(true);
} }

View file

@ -5,6 +5,7 @@ import { doToggleMuteChannel } from 'redux/actions/blocked';
// import { doSetActiveChannel } from 'redux/actions/app'; // import { doSetActiveChannel } from 'redux/actions/app';
import { doSetPlayingUri } from 'redux/actions/content'; import { doSetPlayingUri } from 'redux/actions/content';
import { selectActiveChannelClaim } from 'redux/selectors/app'; import { selectActiveChannelClaim } from 'redux/selectors/app';
import { selectPlayingUri } from 'redux/selectors/content';
import CommentMenuList from './view'; import CommentMenuList from './view';
const select = (state, props) => ({ const select = (state, props) => ({
@ -12,10 +13,11 @@ const select = (state, props) => ({
claimIsMine: makeSelectClaimIsMine(props.uri)(state), claimIsMine: makeSelectClaimIsMine(props.uri)(state),
contentChannelPermanentUrl: makeSelectChannelPermUrlForClaimUri(props.uri)(state), contentChannelPermanentUrl: makeSelectChannelPermUrlForClaimUri(props.uri)(state),
activeChannelClaim: selectActiveChannelClaim(state), activeChannelClaim: selectActiveChannelClaim(state),
playingUri: selectPlayingUri(state),
}); });
const perform = (dispatch) => ({ const perform = (dispatch) => ({
closeInlinePlayer: () => dispatch(doSetPlayingUri({ uri: null })), clearPlayingUri: () => dispatch(doSetPlayingUri({ uri: null })),
deleteComment: (commentId, creatorChannelUrl) => dispatch(doCommentAbandon(commentId, creatorChannelUrl)), deleteComment: (commentId, creatorChannelUrl) => dispatch(doCommentAbandon(commentId, creatorChannelUrl)),
blockChannel: (channelUri) => dispatch(doToggleMuteChannel(channelUri)), blockChannel: (channelUri) => dispatch(doToggleMuteChannel(channelUri)),
pinComment: (commentId, remove) => dispatch(doCommentPin(commentId, remove)), pinComment: (commentId, remove) => dispatch(doCommentPin(commentId, remove)),

View file

@ -7,7 +7,7 @@ import Icon from 'component/common/icon';
type Props = { type Props = {
uri: string, uri: string,
closeInlinePlayer: () => void, clearPlayingUri: () => void,
authorUri: string, // full LBRY Channel URI: lbry://@channel#123... authorUri: string, // full LBRY Channel URI: lbry://@channel#123...
commentId: string, // sha256 digest identifying the comment commentId: string, // sha256 digest identifying the comment
claimIsMine: boolean, // if you control the claim which this comment was posted on claimIsMine: boolean, // if you control the claim which this comment was posted on
@ -24,6 +24,7 @@ type Props = {
claimIsMine: boolean, claimIsMine: boolean,
isTopLevel: boolean, isTopLevel: boolean,
commentModBlock: (string) => void, commentModBlock: (string) => void,
playingUri: ?PlayingUri,
}; };
function CommentMenuList(props: Props) { function CommentMenuList(props: Props) {
@ -36,7 +37,7 @@ function CommentMenuList(props: Props) {
blockChannel, blockChannel,
pinComment, pinComment,
claimIsMine, claimIsMine,
closeInlinePlayer, clearPlayingUri,
activeChannelClaim, activeChannelClaim,
contentChannelPermanentUrl, contentChannelPermanentUrl,
isTopLevel, isTopLevel,
@ -44,6 +45,7 @@ function CommentMenuList(props: Props) {
handleEditComment, handleEditComment,
fetchComments, fetchComments,
commentModBlock, commentModBlock,
playingUri,
} = props; } = props;
const activeChannelIsCreator = activeChannelClaim && activeChannelClaim.permanent_url === contentChannelPermanentUrl; const activeChannelIsCreator = activeChannelClaim && activeChannelClaim.permanent_url === contentChannelPermanentUrl;
@ -52,7 +54,9 @@ function CommentMenuList(props: Props) {
} }
function handleDeleteComment() { function handleDeleteComment() {
closeInlinePlayer(); if (playingUri && playingUri.source === 'comment') {
clearPlayingUri();
}
deleteComment(commentId, commentIsMine ? undefined : contentChannelPermanentUrl); deleteComment(commentId, commentIsMine ? undefined : contentChannelPermanentUrl);
} }