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 { 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)),
});

View file

@ -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);
}

View file

@ -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)),

View file

@ -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);
}