Use 'selectHasChannel' instead of the full 'selectMyChannelClaims'
- selectMyChannelClaims depends on `byId`, which currently is always invalidated per update, so it is not memoized. - Most of the use-cases just needs the ID or the length of the array anyways, so avoid generating a Claim array (in selectMyChannelClaims) unnecessarily -- the client need to reduce it back down to IDs again :/ - The simpler boolean also removes the need to memoize the selector, which saves a bit of memory.
This commit is contained in:
parent
9c5fbe5521
commit
0f1d4039a9
23 changed files with 51 additions and 69 deletions
|
@ -3,7 +3,7 @@ import {
|
||||||
makeSelectStakedLevelForChannelUri,
|
makeSelectStakedLevelForChannelUri,
|
||||||
makeSelectClaimForUri,
|
makeSelectClaimForUri,
|
||||||
makeSelectThumbnailForUri,
|
makeSelectThumbnailForUri,
|
||||||
selectMyChannelClaims,
|
selectHasChannels,
|
||||||
} from 'redux/selectors/claims';
|
} from 'redux/selectors/claims';
|
||||||
import { doCommentUpdate, doCommentList } from 'redux/actions/comments';
|
import { doCommentUpdate, doCommentList } from 'redux/actions/comments';
|
||||||
import { makeSelectChannelIsMuted } from 'redux/selectors/blocked';
|
import { makeSelectChannelIsMuted } from 'redux/selectors/blocked';
|
||||||
|
@ -31,7 +31,7 @@ const select = (state, props) => {
|
||||||
commentingEnabled: IS_WEB ? Boolean(selectUserVerifiedEmail(state)) : true,
|
commentingEnabled: IS_WEB ? Boolean(selectUserVerifiedEmail(state)) : true,
|
||||||
othersReacts: selectOthersReactsForComment(state, reactionKey),
|
othersReacts: selectOthersReactsForComment(state, reactionKey),
|
||||||
activeChannelClaim,
|
activeChannelClaim,
|
||||||
myChannels: selectMyChannelClaims(state),
|
hasChannels: selectHasChannels(state),
|
||||||
playingUri: selectPlayingUri(state),
|
playingUri: selectPlayingUri(state),
|
||||||
stakedLevel: makeSelectStakedLevelForChannelUri(props.authorUri)(state),
|
stakedLevel: makeSelectStakedLevelForChannelUri(props.authorUri)(state),
|
||||||
linkedCommentAncestors: selectLinkedCommentAncestors(state),
|
linkedCommentAncestors: selectLinkedCommentAncestors(state),
|
||||||
|
|
|
@ -49,7 +49,7 @@ type Props = {
|
||||||
commentModBlock: (string) => void,
|
commentModBlock: (string) => void,
|
||||||
linkedCommentId?: string,
|
linkedCommentId?: string,
|
||||||
linkedCommentAncestors: { [string]: Array<string> },
|
linkedCommentAncestors: { [string]: Array<string> },
|
||||||
myChannels: ?Array<ChannelClaim>,
|
hasChannels: boolean,
|
||||||
commentingEnabled: boolean,
|
commentingEnabled: boolean,
|
||||||
doToast: ({ message: string }) => void,
|
doToast: ({ message: string }) => void,
|
||||||
isTopLevel?: boolean,
|
isTopLevel?: boolean,
|
||||||
|
@ -94,7 +94,7 @@ function Comment(props: Props) {
|
||||||
linkedCommentId,
|
linkedCommentId,
|
||||||
linkedCommentAncestors,
|
linkedCommentAncestors,
|
||||||
commentingEnabled,
|
commentingEnabled,
|
||||||
myChannels,
|
hasChannels,
|
||||||
doToast,
|
doToast,
|
||||||
isTopLevel,
|
isTopLevel,
|
||||||
threadDepth,
|
threadDepth,
|
||||||
|
@ -134,7 +134,6 @@ function Comment(props: Props) {
|
||||||
const [page, setPage] = useState(showRepliesOnMount ? 1 : 0);
|
const [page, setPage] = useState(showRepliesOnMount ? 1 : 0);
|
||||||
const [advancedEditor] = usePersistedState('comment-editor-mode', false);
|
const [advancedEditor] = usePersistedState('comment-editor-mode', false);
|
||||||
const [displayDeadComment, setDisplayDeadComment] = React.useState(false);
|
const [displayDeadComment, setDisplayDeadComment] = React.useState(false);
|
||||||
const hasChannels = myChannels && myChannels.length > 0;
|
|
||||||
const likesCount = (othersReacts && othersReacts.like) || 0;
|
const likesCount = (othersReacts && othersReacts.like) || 0;
|
||||||
const dislikesCount = (othersReacts && othersReacts.dislike) || 0;
|
const dislikesCount = (othersReacts && othersReacts.dislike) || 0;
|
||||||
const totalLikesAndDislikes = likesCount + dislikesCount;
|
const totalLikesAndDislikes = likesCount + dislikesCount;
|
||||||
|
|
|
@ -2,7 +2,7 @@ import { connect } from 'react-redux';
|
||||||
import {
|
import {
|
||||||
makeSelectClaimForUri,
|
makeSelectClaimForUri,
|
||||||
makeSelectClaimIsMine,
|
makeSelectClaimIsMine,
|
||||||
selectMyChannelClaims,
|
selectHasChannels,
|
||||||
selectFetchingMyChannels,
|
selectFetchingMyChannels,
|
||||||
makeSelectTagInClaimOrChannelForUri,
|
makeSelectTagInClaimOrChannelForUri,
|
||||||
} from 'redux/selectors/claims';
|
} from 'redux/selectors/claims';
|
||||||
|
@ -16,7 +16,7 @@ import { selectSettingsByChannelId } from 'redux/selectors/comments';
|
||||||
|
|
||||||
const select = (state, props) => ({
|
const select = (state, props) => ({
|
||||||
activeChannelClaim: selectActiveChannelClaim(state),
|
activeChannelClaim: selectActiveChannelClaim(state),
|
||||||
channels: selectMyChannelClaims(state),
|
hasChannels: selectHasChannels(state),
|
||||||
claim: makeSelectClaimForUri(props.uri)(state),
|
claim: makeSelectClaimForUri(props.uri)(state),
|
||||||
claimIsMine: makeSelectClaimIsMine(props.uri)(state),
|
claimIsMine: makeSelectClaimIsMine(props.uri)(state),
|
||||||
isFetchingChannels: selectFetchingMyChannels(state),
|
isFetchingChannels: selectFetchingMyChannels(state),
|
||||||
|
|
|
@ -43,7 +43,7 @@ type Props = {
|
||||||
activeChannel: string,
|
activeChannel: string,
|
||||||
activeChannelClaim: ?ChannelClaim,
|
activeChannelClaim: ?ChannelClaim,
|
||||||
bottom: boolean,
|
bottom: boolean,
|
||||||
channels: ?Array<ChannelClaim>,
|
hasChannels: boolean,
|
||||||
claim: StreamClaim,
|
claim: StreamClaim,
|
||||||
claimIsMine: boolean,
|
claimIsMine: boolean,
|
||||||
embed?: boolean,
|
embed?: boolean,
|
||||||
|
@ -72,7 +72,7 @@ export function CommentCreate(props: Props) {
|
||||||
const {
|
const {
|
||||||
activeChannelClaim,
|
activeChannelClaim,
|
||||||
bottom,
|
bottom,
|
||||||
channels,
|
hasChannels,
|
||||||
claim,
|
claim,
|
||||||
claimIsMine,
|
claimIsMine,
|
||||||
embed,
|
embed,
|
||||||
|
@ -146,7 +146,6 @@ export function CommentCreate(props: Props) {
|
||||||
|
|
||||||
const claimId = claim && claim.claim_id;
|
const claimId = claim && claim.claim_id;
|
||||||
const channelUri = claim && (claim.signing_channel ? claim.signing_channel.permanent_url : claim.permanent_url);
|
const channelUri = claim && (claim.signing_channel ? claim.signing_channel.permanent_url : claim.permanent_url);
|
||||||
const hasChannels = channels && channels.length;
|
|
||||||
const charCount = commentValue ? commentValue.length : 0;
|
const charCount = commentValue ? commentValue.length : 0;
|
||||||
const disabled = deletedComment || isSubmitting || isFetchingChannels || !commentValue.length || pauseQuickSend;
|
const disabled = deletedComment || isSubmitting || isFetchingChannels || !commentValue.length || pauseQuickSend;
|
||||||
const channelId = getChannelIdFromClaim(claim);
|
const channelId = getChannelIdFromClaim(claim);
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import { connect } from 'react-redux';
|
import { connect } from 'react-redux';
|
||||||
import { doResolveUris } from 'redux/actions/claims';
|
import { doResolveUris } from 'redux/actions/claims';
|
||||||
import { makeSelectClaimIsMine, selectMyChannelClaims, makeSelectClaimForUri } from 'redux/selectors/claims';
|
import { makeSelectClaimIsMine, selectMyChannelClaimIds, makeSelectClaimForUri } from 'redux/selectors/claims';
|
||||||
import { selectIsFetchingCommentsByParentId, selectRepliesForParentId } from 'redux/selectors/comments';
|
import { selectIsFetchingCommentsByParentId, selectRepliesForParentId } from 'redux/selectors/comments';
|
||||||
import { selectUserVerifiedEmail } from 'redux/selectors/user';
|
import { selectUserVerifiedEmail } from 'redux/selectors/user';
|
||||||
import CommentsReplies from './view';
|
import CommentsReplies from './view';
|
||||||
|
@ -17,7 +17,7 @@ const select = (state, props) => {
|
||||||
resolvedReplies,
|
resolvedReplies,
|
||||||
claimIsMine: makeSelectClaimIsMine(props.uri)(state),
|
claimIsMine: makeSelectClaimIsMine(props.uri)(state),
|
||||||
userCanComment: IS_WEB ? Boolean(selectUserVerifiedEmail(state)) : true,
|
userCanComment: IS_WEB ? Boolean(selectUserVerifiedEmail(state)) : true,
|
||||||
myChannels: selectMyChannelClaims(state),
|
myChannelIds: selectMyChannelClaimIds(state),
|
||||||
isFetchingByParentId: selectIsFetchingCommentsByParentId(state),
|
isFetchingByParentId: selectIsFetchingCommentsByParentId(state),
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
|
@ -11,7 +11,7 @@ type Props = {
|
||||||
uri: string,
|
uri: string,
|
||||||
parentId: string,
|
parentId: string,
|
||||||
claimIsMine: boolean,
|
claimIsMine: boolean,
|
||||||
myChannels: ?Array<ChannelClaim>,
|
myChannelIds: ?Array<string>,
|
||||||
linkedCommentId?: string,
|
linkedCommentId?: string,
|
||||||
userCanComment: boolean,
|
userCanComment: boolean,
|
||||||
threadDepth: number,
|
threadDepth: number,
|
||||||
|
@ -30,7 +30,7 @@ function CommentsReplies(props: Props) {
|
||||||
fetchedReplies,
|
fetchedReplies,
|
||||||
resolvedReplies,
|
resolvedReplies,
|
||||||
claimIsMine,
|
claimIsMine,
|
||||||
myChannels,
|
myChannelIds,
|
||||||
linkedCommentId,
|
linkedCommentId,
|
||||||
userCanComment,
|
userCanComment,
|
||||||
threadDepth,
|
threadDepth,
|
||||||
|
@ -95,11 +95,7 @@ function CommentsReplies(props: Props) {
|
||||||
message={comment.comment}
|
message={comment.comment}
|
||||||
timePosted={comment.timestamp * 1000}
|
timePosted={comment.timestamp * 1000}
|
||||||
claimIsMine={claimIsMine}
|
claimIsMine={claimIsMine}
|
||||||
commentIsMine={
|
commentIsMine={comment.channel_id && myChannelIds && myChannelIds.includes(comment.channel_id)}
|
||||||
comment.channel_id &&
|
|
||||||
myChannels &&
|
|
||||||
myChannels.some(({ claim_id }) => claim_id === comment.channel_id)
|
|
||||||
}
|
|
||||||
linkedCommentId={linkedCommentId}
|
linkedCommentId={linkedCommentId}
|
||||||
commentingEnabled={userCanComment}
|
commentingEnabled={userCanComment}
|
||||||
supportAmount={comment.support_amount}
|
supportAmount={comment.support_amount}
|
||||||
|
|
|
@ -2,7 +2,7 @@ import { connect } from 'react-redux';
|
||||||
import {
|
import {
|
||||||
makeSelectClaimIsMine,
|
makeSelectClaimIsMine,
|
||||||
makeSelectClaimForUri,
|
makeSelectClaimForUri,
|
||||||
selectMyChannelClaims,
|
selectHasChannels,
|
||||||
makeSelectClaimIsStreamPlaceholder,
|
makeSelectClaimIsStreamPlaceholder,
|
||||||
makeSelectTagInClaimOrChannelForUri,
|
makeSelectTagInClaimOrChannelForUri,
|
||||||
} from 'redux/selectors/claims';
|
} from 'redux/selectors/claims';
|
||||||
|
@ -23,7 +23,7 @@ const select = (state, props) => ({
|
||||||
fileInfo: makeSelectFileInfoForUri(props.uri)(state),
|
fileInfo: makeSelectFileInfoForUri(props.uri)(state),
|
||||||
renderMode: makeSelectFileRenderModeForUri(props.uri)(state),
|
renderMode: makeSelectFileRenderModeForUri(props.uri)(state),
|
||||||
costInfo: makeSelectCostInfoForUri(props.uri)(state),
|
costInfo: makeSelectCostInfoForUri(props.uri)(state),
|
||||||
myChannels: selectMyChannelClaims(state),
|
hasChannels: selectHasChannels(state),
|
||||||
isLivestreamClaim: makeSelectClaimIsStreamPlaceholder(props.uri)(state),
|
isLivestreamClaim: makeSelectClaimIsStreamPlaceholder(props.uri)(state),
|
||||||
reactionsDisabled: makeSelectTagInClaimOrChannelForUri(props.uri, DISABLE_COMMENTS_TAG)(state),
|
reactionsDisabled: makeSelectTagInClaimOrChannelForUri(props.uri, DISABLE_COMMENTS_TAG)(state),
|
||||||
streamingUrl: makeSelectStreamingUrlForUri(props.uri)(state),
|
streamingUrl: makeSelectStreamingUrlForUri(props.uri)(state),
|
||||||
|
|
|
@ -27,7 +27,7 @@ type Props = {
|
||||||
fileInfo: FileListItem,
|
fileInfo: FileListItem,
|
||||||
costInfo: ?{ cost: number },
|
costInfo: ?{ cost: number },
|
||||||
renderMode: string,
|
renderMode: string,
|
||||||
myChannels: ?Array<ChannelClaim>,
|
hasChannels: boolean,
|
||||||
doToast: ({ message: string }) => void,
|
doToast: ({ message: string }) => void,
|
||||||
clearPlayingUri: () => void,
|
clearPlayingUri: () => void,
|
||||||
hideRepost?: boolean,
|
hideRepost?: boolean,
|
||||||
|
@ -47,7 +47,7 @@ function FileActions(props: Props) {
|
||||||
costInfo,
|
costInfo,
|
||||||
renderMode,
|
renderMode,
|
||||||
prepareEdit,
|
prepareEdit,
|
||||||
myChannels,
|
hasChannels,
|
||||||
clearPlayingUri,
|
clearPlayingUri,
|
||||||
doToast,
|
doToast,
|
||||||
hideRepost,
|
hideRepost,
|
||||||
|
@ -63,7 +63,6 @@ function FileActions(props: Props) {
|
||||||
const isMobile = useIsMobile();
|
const isMobile = useIsMobile();
|
||||||
const webShareable = costInfo && costInfo.cost === 0 && RENDER_MODES.WEB_SHAREABLE_MODES.includes(renderMode);
|
const webShareable = costInfo && costInfo.cost === 0 && RENDER_MODES.WEB_SHAREABLE_MODES.includes(renderMode);
|
||||||
const showDelete = claimIsMine || (fileInfo && (fileInfo.written_bytes > 0 || fileInfo.blobs_completed > 0));
|
const showDelete = claimIsMine || (fileInfo && (fileInfo.written_bytes > 0 || fileInfo.blobs_completed > 0));
|
||||||
const hasChannels = myChannels && myChannels.length > 0;
|
|
||||||
const claimId = claim && claim.claim_id;
|
const claimId = claim && claim.claim_id;
|
||||||
const { signing_channel: signingChannel } = claim;
|
const { signing_channel: signingChannel } = claim;
|
||||||
const channelName = signingChannel && signingChannel.name;
|
const channelName = signingChannel && signingChannel.name;
|
||||||
|
|
|
@ -15,7 +15,7 @@ import {
|
||||||
selectIsResolvingPublishUris,
|
selectIsResolvingPublishUris,
|
||||||
selectMyClaimForUri,
|
selectMyClaimForUri,
|
||||||
} from 'redux/selectors/publish';
|
} from 'redux/selectors/publish';
|
||||||
import { selectMyChannelClaims, makeSelectClaimIsStreamPlaceholder } from 'redux/selectors/claims';
|
import { makeSelectClaimIsStreamPlaceholder } from 'redux/selectors/claims';
|
||||||
import * as RENDER_MODES from 'constants/file_render_modes';
|
import * as RENDER_MODES from 'constants/file_render_modes';
|
||||||
import * as SETTINGS from 'constants/settings';
|
import * as SETTINGS from 'constants/settings';
|
||||||
import { doClaimInitialRewards } from 'redux/actions/rewards';
|
import { doClaimInitialRewards } from 'redux/actions/rewards';
|
||||||
|
@ -33,7 +33,7 @@ import {
|
||||||
import { makeSelectClientSetting } from 'redux/selectors/settings';
|
import { makeSelectClientSetting } from 'redux/selectors/settings';
|
||||||
import { makeSelectFileRenderModeForUri } from 'redux/selectors/content';
|
import { makeSelectFileRenderModeForUri } from 'redux/selectors/content';
|
||||||
import { selectUser } from 'redux/selectors/user';
|
import { selectUser } from 'redux/selectors/user';
|
||||||
import PublishPage from './view';
|
import PublishForm from './view';
|
||||||
|
|
||||||
const select = (state) => {
|
const select = (state) => {
|
||||||
const myClaimForUri = selectMyClaimForUri(state);
|
const myClaimForUri = selectMyClaimForUri(state);
|
||||||
|
@ -61,7 +61,6 @@ const select = (state) => {
|
||||||
modal: selectModal(state),
|
modal: selectModal(state),
|
||||||
enablePublishPreview: makeSelectClientSetting(SETTINGS.ENABLE_PUBLISH_PREVIEW)(state),
|
enablePublishPreview: makeSelectClientSetting(SETTINGS.ENABLE_PUBLISH_PREVIEW)(state),
|
||||||
activeChannelClaim: selectActiveChannelClaim(state),
|
activeChannelClaim: selectActiveChannelClaim(state),
|
||||||
myChannels: selectMyChannelClaims(state),
|
|
||||||
incognito: selectIncognito(state),
|
incognito: selectIncognito(state),
|
||||||
activeChannelStakedLevel: selectActiveChannelStakedLevel(state),
|
activeChannelStakedLevel: selectActiveChannelStakedLevel(state),
|
||||||
isClaimingInitialRewards: selectIsClaimingInitialRewards(state),
|
isClaimingInitialRewards: selectIsClaimingInitialRewards(state),
|
||||||
|
@ -80,4 +79,4 @@ const perform = (dispatch) => ({
|
||||||
claimInitialRewards: () => dispatch(doClaimInitialRewards()),
|
claimInitialRewards: () => dispatch(doClaimInitialRewards()),
|
||||||
});
|
});
|
||||||
|
|
||||||
export default connect(select, perform)(PublishPage);
|
export default connect(select, perform)(PublishForm);
|
||||||
|
|
|
@ -3,7 +3,6 @@ import { doHideModal } from 'redux/actions/app';
|
||||||
import {
|
import {
|
||||||
makeSelectClaimForUri,
|
makeSelectClaimForUri,
|
||||||
makeSelectTitleForUri,
|
makeSelectTitleForUri,
|
||||||
selectMyChannelClaims,
|
|
||||||
selectRepostError,
|
selectRepostError,
|
||||||
selectRepostLoading,
|
selectRepostLoading,
|
||||||
selectMyClaimsWithoutChannels,
|
selectMyClaimsWithoutChannels,
|
||||||
|
@ -24,7 +23,6 @@ import { selectActiveChannelClaim, selectIncognito } from 'redux/selectors/app';
|
||||||
import RepostCreate from './view';
|
import RepostCreate from './view';
|
||||||
|
|
||||||
const select = (state, props) => ({
|
const select = (state, props) => ({
|
||||||
channels: selectMyChannelClaims(state),
|
|
||||||
claim: makeSelectClaimForUri(props.uri)(state),
|
claim: makeSelectClaimForUri(props.uri)(state),
|
||||||
passedRepostClaim: makeSelectClaimForUri(props.name, false)(state),
|
passedRepostClaim: makeSelectClaimForUri(props.name, false)(state),
|
||||||
passedRepostAmount: makeSelectEffectiveAmountForUri(props.name)(state),
|
passedRepostAmount: makeSelectEffectiveAmountForUri(props.name)(state),
|
||||||
|
|
|
@ -27,7 +27,6 @@ type Props = {
|
||||||
claim?: StreamClaim,
|
claim?: StreamClaim,
|
||||||
enteredContentClaim?: StreamClaim,
|
enteredContentClaim?: StreamClaim,
|
||||||
balance: number,
|
balance: number,
|
||||||
channels: ?Array<ChannelClaim>,
|
|
||||||
doCheckPublishNameAvailability: (string) => Promise<*>,
|
doCheckPublishNameAvailability: (string) => Promise<*>,
|
||||||
error: ?string,
|
error: ?string,
|
||||||
reposting: boolean,
|
reposting: boolean,
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import { connect } from 'react-redux';
|
import { connect } from 'react-redux';
|
||||||
import { selectMyChannelClaims } from 'redux/selectors/claims';
|
import { selectHasChannels } from 'redux/selectors/claims';
|
||||||
import { selectWalletIsEncrypted } from 'redux/selectors/wallet';
|
import { selectWalletIsEncrypted } from 'redux/selectors/wallet';
|
||||||
import { doWalletStatus } from 'redux/actions/wallet';
|
import { doWalletStatus } from 'redux/actions/wallet';
|
||||||
import { selectUser, selectUserVerifiedEmail } from 'redux/selectors/user';
|
import { selectUser, selectUserVerifiedEmail } from 'redux/selectors/user';
|
||||||
|
@ -11,7 +11,7 @@ const select = (state) => ({
|
||||||
isAuthenticated: selectUserVerifiedEmail(state),
|
isAuthenticated: selectUserVerifiedEmail(state),
|
||||||
walletEncrypted: selectWalletIsEncrypted(state),
|
walletEncrypted: selectWalletIsEncrypted(state),
|
||||||
user: selectUser(state),
|
user: selectUser(state),
|
||||||
myChannels: selectMyChannelClaims(state),
|
hasChannels: selectHasChannels(state),
|
||||||
language: selectLanguage(state),
|
language: selectLanguage(state),
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -11,17 +11,16 @@ import { getPasswordFromCookie } from 'util/saved-passwords';
|
||||||
import { getStripeEnvironment } from 'util/stripe';
|
import { getStripeEnvironment } from 'util/stripe';
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
// --- select ---
|
// --- redux ---
|
||||||
isAuthenticated: boolean,
|
isAuthenticated: boolean,
|
||||||
walletEncrypted: boolean,
|
walletEncrypted: boolean,
|
||||||
user: User,
|
user: User,
|
||||||
myChannels: ?Array<ChannelClaim>,
|
hasChannels: boolean,
|
||||||
// --- perform ---
|
|
||||||
doWalletStatus: () => void,
|
doWalletStatus: () => void,
|
||||||
};
|
};
|
||||||
|
|
||||||
export default function SettingAccount(props: Props) {
|
export default function SettingAccount(props: Props) {
|
||||||
const { isAuthenticated, walletEncrypted, user, myChannels, doWalletStatus } = props;
|
const { isAuthenticated, walletEncrypted, user, hasChannels, doWalletStatus } = props;
|
||||||
const [storedPassword, setStoredPassword] = React.useState(false);
|
const [storedPassword, setStoredPassword] = React.useState(false);
|
||||||
|
|
||||||
// Determine if password is stored.
|
// Determine if password is stored.
|
||||||
|
@ -94,7 +93,7 @@ export default function SettingAccount(props: Props) {
|
||||||
)}
|
)}
|
||||||
{/* @endif */}
|
{/* @endif */}
|
||||||
|
|
||||||
{myChannels && (
|
{hasChannels && (
|
||||||
<SettingsRow title={__('Comments')} subtitle={__('View your past comments.')}>
|
<SettingsRow title={__('Comments')} subtitle={__('View your past comments.')}>
|
||||||
<Button
|
<Button
|
||||||
button="inverse"
|
button="inverse"
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import { connect } from 'react-redux';
|
import { connect } from 'react-redux';
|
||||||
import { selectBalance } from 'redux/selectors/wallet';
|
import { selectBalance } from 'redux/selectors/wallet';
|
||||||
import { selectMyChannelClaims, makeSelectClaimForUri } from 'redux/selectors/claims';
|
import { makeSelectClaimForUri } from 'redux/selectors/claims';
|
||||||
import { doOpenModal } from 'redux/actions/app';
|
import { doOpenModal } from 'redux/actions/app';
|
||||||
import WalletSend from './view';
|
import WalletSend from './view';
|
||||||
import { withRouter } from 'react-router';
|
import { withRouter } from 'react-router';
|
||||||
|
@ -12,7 +12,6 @@ const perform = (dispatch) => ({
|
||||||
|
|
||||||
const select = (state, props) => ({
|
const select = (state, props) => ({
|
||||||
balance: selectBalance(state),
|
balance: selectBalance(state),
|
||||||
channels: selectMyChannelClaims(state),
|
|
||||||
contentClaim: makeSelectClaimForUri(props.contentUri)(state),
|
contentClaim: makeSelectClaimForUri(props.contentUri)(state),
|
||||||
snack: selectToast(state),
|
snack: selectToast(state),
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,10 +1,5 @@
|
||||||
import { connect } from 'react-redux';
|
import { connect } from 'react-redux';
|
||||||
import {
|
import { selectMyChannelUrls, selectFetchingMyChannels, makeSelectClaimIsPending } from 'redux/selectors/claims';
|
||||||
selectMyChannelClaims,
|
|
||||||
selectMyChannelUrls,
|
|
||||||
selectFetchingMyChannels,
|
|
||||||
makeSelectClaimIsPending,
|
|
||||||
} from 'redux/selectors/claims';
|
|
||||||
import { doFetchChannelListMine } from 'redux/actions/claims';
|
import { doFetchChannelListMine } from 'redux/actions/claims';
|
||||||
import { doSetActiveChannel } from 'redux/actions/app';
|
import { doSetActiveChannel } from 'redux/actions/app';
|
||||||
import { selectYoutubeChannels } from 'redux/selectors/user';
|
import { selectYoutubeChannels } from 'redux/selectors/user';
|
||||||
|
@ -22,7 +17,6 @@ const select = (state) => {
|
||||||
|
|
||||||
return {
|
return {
|
||||||
channelUrls,
|
channelUrls,
|
||||||
channels: selectMyChannelClaims(state),
|
|
||||||
fetchingChannels: selectFetchingMyChannels(state),
|
fetchingChannels: selectFetchingMyChannels(state),
|
||||||
youtubeChannels: selectYoutubeChannels(state),
|
youtubeChannels: selectYoutubeChannels(state),
|
||||||
pendingChannels,
|
pendingChannels,
|
||||||
|
|
|
@ -14,7 +14,6 @@ import HelpLink from 'component/common/help-link';
|
||||||
import { useHistory } from 'react-router';
|
import { useHistory } from 'react-router';
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
channels: Array<ChannelClaim>,
|
|
||||||
channelUrls: Array<string>,
|
channelUrls: Array<string>,
|
||||||
fetchChannelListMine: () => void,
|
fetchChannelListMine: () => void,
|
||||||
fetchingChannels: boolean,
|
fetchingChannels: boolean,
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
import { connect } from 'react-redux';
|
import { connect } from 'react-redux';
|
||||||
import { selectMyChannelClaims, selectFetchingMyChannels } from 'redux/selectors/claims';
|
import { selectHasChannels, selectFetchingMyChannels } from 'redux/selectors/claims';
|
||||||
import { selectActiveChannelClaim } from 'redux/selectors/app';
|
import { selectActiveChannelClaim } from 'redux/selectors/app';
|
||||||
import { doSetActiveChannel } from 'redux/actions/app';
|
import { doSetActiveChannel } from 'redux/actions/app';
|
||||||
import CreatorDashboardPage from './view';
|
import CreatorDashboardPage from './view';
|
||||||
|
|
||||||
const select = (state) => ({
|
const select = (state) => ({
|
||||||
channels: selectMyChannelClaims(state),
|
hasChannels: selectHasChannels(state),
|
||||||
fetchingChannels: selectFetchingMyChannels(state),
|
fetchingChannels: selectFetchingMyChannels(state),
|
||||||
activeChannelClaim: selectActiveChannelClaim(state),
|
activeChannelClaim: selectActiveChannelClaim(state),
|
||||||
});
|
});
|
||||||
|
|
|
@ -9,14 +9,13 @@ import ChannelSelector from 'component/channelSelector';
|
||||||
import Yrbl from 'component/yrbl';
|
import Yrbl from 'component/yrbl';
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
channels: Array<ChannelClaim>,
|
hasChannels: boolean,
|
||||||
fetchingChannels: boolean,
|
fetchingChannels: boolean,
|
||||||
activeChannelClaim: ?ChannelClaim,
|
activeChannelClaim: ?ChannelClaim,
|
||||||
};
|
};
|
||||||
|
|
||||||
export default function CreatorDashboardPage(props: Props) {
|
export default function CreatorDashboardPage(props: Props) {
|
||||||
const { channels, fetchingChannels, activeChannelClaim } = props;
|
const { hasChannels, fetchingChannels, activeChannelClaim } = props;
|
||||||
const hasChannels = channels && channels.length > 0;
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Page>
|
<Page>
|
||||||
|
|
|
@ -12,7 +12,7 @@ import {
|
||||||
selectModeratorTimeoutMap,
|
selectModeratorTimeoutMap,
|
||||||
selectPersonalTimeoutMap,
|
selectPersonalTimeoutMap,
|
||||||
} from 'redux/selectors/comments';
|
} from 'redux/selectors/comments';
|
||||||
import { selectMyChannelClaims } from 'redux/selectors/claims';
|
import { selectMyChannelClaimIds } from 'redux/selectors/claims';
|
||||||
import ListBlocked from './view';
|
import ListBlocked from './view';
|
||||||
|
|
||||||
const select = (state) => ({
|
const select = (state) => ({
|
||||||
|
@ -25,7 +25,7 @@ const select = (state) => ({
|
||||||
moderatorTimeoutMap: selectModeratorTimeoutMap(state),
|
moderatorTimeoutMap: selectModeratorTimeoutMap(state),
|
||||||
moderatorBlockListDelegatorsMap: selectModeratorBlockListDelegatorsMap(state),
|
moderatorBlockListDelegatorsMap: selectModeratorBlockListDelegatorsMap(state),
|
||||||
delegatorsById: selectModerationDelegatorsById(state),
|
delegatorsById: selectModerationDelegatorsById(state),
|
||||||
myChannelClaims: selectMyChannelClaims(state),
|
myChannelClaimIds: selectMyChannelClaimIds(state),
|
||||||
fetchingModerationBlockList: selectFetchingModerationBlockList(state),
|
fetchingModerationBlockList: selectFetchingModerationBlockList(state),
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -34,7 +34,7 @@ type Props = {
|
||||||
fetchModBlockedList: () => void,
|
fetchModBlockedList: () => void,
|
||||||
fetchModAmIList: () => void,
|
fetchModAmIList: () => void,
|
||||||
delegatorsById: { [string]: { global: boolean, delegators: { name: string, claimId: string } } },
|
delegatorsById: { [string]: { global: boolean, delegators: { name: string, claimId: string } } },
|
||||||
myChannelClaims: ?Array<ChannelClaim>,
|
myChannelClaimIds: ?Array<string>,
|
||||||
};
|
};
|
||||||
|
|
||||||
function ListBlocked(props: Props) {
|
function ListBlocked(props: Props) {
|
||||||
|
@ -51,7 +51,7 @@ function ListBlocked(props: Props) {
|
||||||
fetchModBlockedList,
|
fetchModBlockedList,
|
||||||
fetchModAmIList,
|
fetchModAmIList,
|
||||||
delegatorsById,
|
delegatorsById,
|
||||||
myChannelClaims,
|
myChannelClaimIds,
|
||||||
} = props;
|
} = props;
|
||||||
const [viewMode, setViewMode] = usePersistedState('blocked-muted:display', VIEW.BLOCKED);
|
const [viewMode, setViewMode] = usePersistedState('blocked-muted:display', VIEW.BLOCKED);
|
||||||
|
|
||||||
|
@ -60,14 +60,11 @@ function ListBlocked(props: Props) {
|
||||||
const stringifiedDelegatorsMap = JSON.stringify(delegatorsMap);
|
const stringifiedDelegatorsMap = JSON.stringify(delegatorsMap);
|
||||||
const stringifiedLocalDelegatorsMap = JSON.stringify(localDelegatorsMap);
|
const stringifiedLocalDelegatorsMap = JSON.stringify(localDelegatorsMap);
|
||||||
|
|
||||||
const isAdmin =
|
const isAdmin = myChannelClaimIds && myChannelClaimIds.some((id) => delegatorsById[id] && delegatorsById[id].global);
|
||||||
myChannelClaims && myChannelClaims.some((c) => delegatorsById[c.claim_id] && delegatorsById[c.claim_id].global);
|
|
||||||
|
|
||||||
const isModerator =
|
const isModerator =
|
||||||
myChannelClaims &&
|
myChannelClaimIds &&
|
||||||
myChannelClaims.some(
|
myChannelClaimIds.some((id) => delegatorsById[id] && Object.keys(delegatorsById[id].delegators).length > 0);
|
||||||
(c) => delegatorsById[c.claim_id] && Object.keys(delegatorsById[c.claim_id].delegators).length > 0
|
|
||||||
);
|
|
||||||
|
|
||||||
// **************************************************************************
|
// **************************************************************************
|
||||||
|
|
||||||
|
@ -221,7 +218,7 @@ function ListBlocked(props: Props) {
|
||||||
|
|
||||||
function getRefreshElem() {
|
function getRefreshElem() {
|
||||||
return (
|
return (
|
||||||
myChannelClaims && (
|
myChannelClaimIds && (
|
||||||
<Button
|
<Button
|
||||||
icon={ICONS.REFRESH}
|
icon={ICONS.REFRESH}
|
||||||
button="alt"
|
button="alt"
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import { connect } from 'react-redux';
|
import { connect } from 'react-redux';
|
||||||
import { selectMyChannelClaims, selectFetchingMyChannels } from 'redux/selectors/claims';
|
import { selectHasChannels, selectFetchingMyChannels } from 'redux/selectors/claims';
|
||||||
import { doClearPublish } from 'redux/actions/publish';
|
import { doClearPublish } from 'redux/actions/publish';
|
||||||
import { selectActiveChannelClaim } from 'redux/selectors/app';
|
import { selectActiveChannelClaim } from 'redux/selectors/app';
|
||||||
import { doFetchNoSourceClaims } from 'redux/actions/livestream';
|
import { doFetchNoSourceClaims } from 'redux/actions/livestream';
|
||||||
|
@ -17,7 +17,7 @@ const select = (state) => {
|
||||||
return {
|
return {
|
||||||
channelName,
|
channelName,
|
||||||
channelId,
|
channelId,
|
||||||
channels: selectMyChannelClaims(state),
|
hasChannels: selectHasChannels(state),
|
||||||
fetchingChannels: selectFetchingMyChannels(state),
|
fetchingChannels: selectFetchingMyChannels(state),
|
||||||
activeChannelClaim,
|
activeChannelClaim,
|
||||||
myLivestreamClaims: makeSelectLivestreamsForChannelId(channelId)(state),
|
myLivestreamClaims: makeSelectLivestreamsForChannelId(channelId)(state),
|
||||||
|
|
|
@ -19,7 +19,7 @@ import usePersistedState from 'effects/use-persisted-state';
|
||||||
import { LIVESTREAM_RTMP_URL } from 'constants/livestream';
|
import { LIVESTREAM_RTMP_URL } from 'constants/livestream';
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
channels: Array<ChannelClaim>,
|
hasChannels: boolean,
|
||||||
fetchingChannels: boolean,
|
fetchingChannels: boolean,
|
||||||
activeChannelClaim: ?ChannelClaim,
|
activeChannelClaim: ?ChannelClaim,
|
||||||
pendingClaims: Array<Claim>,
|
pendingClaims: Array<Claim>,
|
||||||
|
@ -34,7 +34,7 @@ type Props = {
|
||||||
export default function LivestreamSetupPage(props: Props) {
|
export default function LivestreamSetupPage(props: Props) {
|
||||||
const LIVESTREAM_CLAIM_POLL_IN_MS = 60000;
|
const LIVESTREAM_CLAIM_POLL_IN_MS = 60000;
|
||||||
const {
|
const {
|
||||||
channels,
|
hasChannels,
|
||||||
fetchingChannels,
|
fetchingChannels,
|
||||||
activeChannelClaim,
|
activeChannelClaim,
|
||||||
pendingClaims,
|
pendingClaims,
|
||||||
|
@ -49,7 +49,6 @@ export default function LivestreamSetupPage(props: Props) {
|
||||||
const [sigData, setSigData] = React.useState({ signature: undefined, signing_ts: undefined });
|
const [sigData, setSigData] = React.useState({ signature: undefined, signing_ts: undefined });
|
||||||
const [showHelp, setShowHelp] = usePersistedState('livestream-help-seen', true);
|
const [showHelp, setShowHelp] = usePersistedState('livestream-help-seen', true);
|
||||||
|
|
||||||
const hasChannels = channels && channels.length > 0;
|
|
||||||
const hasLivestreamClaims = Boolean(myLivestreamClaims.length || pendingClaims.length);
|
const hasLivestreamClaims = Boolean(myLivestreamClaims.length || pendingClaims.length);
|
||||||
|
|
||||||
function createStreamKey() {
|
function createStreamKey() {
|
||||||
|
|
|
@ -402,6 +402,8 @@ export const selectMyClaimsOutpoints = createSelector(selectMyClaims, (myClaims)
|
||||||
export const selectFetchingMyChannels = (state: State) => selectState(state).fetchingMyChannels;
|
export const selectFetchingMyChannels = (state: State) => selectState(state).fetchingMyChannels;
|
||||||
export const selectFetchingMyCollections = (state: State) => selectState(state).fetchingMyCollections;
|
export const selectFetchingMyCollections = (state: State) => selectState(state).fetchingMyCollections;
|
||||||
|
|
||||||
|
export const selectMyChannelClaimIds = (state: State) => selectState(state).myChannelClaims;
|
||||||
|
|
||||||
export const selectMyChannelClaims = createSelector(selectState, selectClaimsById, (state, byId) => {
|
export const selectMyChannelClaims = createSelector(selectState, selectClaimsById, (state, byId) => {
|
||||||
const ids = state.myChannelClaims;
|
const ids = state.myChannelClaims;
|
||||||
if (!ids) {
|
if (!ids) {
|
||||||
|
@ -423,6 +425,11 @@ export const selectMyChannelUrls = createSelector(selectMyChannelClaims, (claims
|
||||||
claims ? claims.map((claim) => claim.canonical_url || claim.permanent_url) : undefined
|
claims ? claims.map((claim) => claim.canonical_url || claim.permanent_url) : undefined
|
||||||
);
|
);
|
||||||
|
|
||||||
|
export const selectHasChannels = (state: State) => {
|
||||||
|
const myChannelClaimIds = selectMyChannelClaimIds(state);
|
||||||
|
return myChannelClaimIds ? myChannelClaimIds.length > 0 : false;
|
||||||
|
};
|
||||||
|
|
||||||
export const selectMyCollectionIds = (state: State) => selectState(state).myCollectionClaims;
|
export const selectMyCollectionIds = (state: State) => selectState(state).myCollectionClaims;
|
||||||
|
|
||||||
export const selectResolvingUris = createSelector(selectState, (state) => state.resolvingUris || []);
|
export const selectResolvingUris = createSelector(selectState, (state) => state.resolvingUris || []);
|
||||||
|
|
Loading…
Add table
Reference in a new issue