From ca0cd2ca751457d5f0d1cef8f510908eb7833431 Mon Sep 17 00:00:00 2001 From: jessopb <36554050+jessopb@users.noreply.github.com> Date: Fri, 21 Jan 2022 12:38:11 -0500 Subject: [PATCH] Use 'selectHasChannel' instead of the full 'selectMyChannelClaims' (#7427) - 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. Co-authored-by: infinite-persistence --- ui/component/comment/index.js | 4 +--- ui/component/comment/view.jsx | 5 ++--- ui/component/fileActions/view.jsx | 9 +++------ ui/component/publishForm/index.js | 6 ++---- ui/component/repostCreate/index.js | 2 -- ui/component/repostCreate/view.jsx | 1 - ui/component/settingAccount/index.js | 4 ++-- ui/component/settingAccount/view.jsx | 8 +++----- ui/component/walletSend/index.js | 3 +-- ui/page/channels/index.js | 8 +------- ui/page/channels/view.jsx | 1 - ui/page/creatorDashboard/index.js | 4 ++-- ui/page/creatorDashboard/view.jsx | 5 ++--- ui/page/listBlocked/index.js | 4 ++-- ui/page/listBlocked/view.jsx | 15 ++++++--------- 15 files changed, 27 insertions(+), 52 deletions(-) diff --git a/ui/component/comment/index.js b/ui/component/comment/index.js index 743faac8d..553b10a57 100644 --- a/ui/component/comment/index.js +++ b/ui/component/comment/index.js @@ -4,7 +4,6 @@ import { makeSelectClaimForUri, selectThumbnailForUri, selectHasChannels, - selectMyChannelClaims, } from 'redux/selectors/claims'; import { doCommentUpdate, doCommentList } from 'redux/actions/comments'; import { makeSelectChannelIsMuted } from 'redux/selectors/blocked'; @@ -31,8 +30,7 @@ const select = (state, props) => { commentingEnabled: true, othersReacts: selectOthersReactsForComment(state, reactionKey), activeChannelClaim, - hasChannels: selectHasChannels(state), // - myChannels: selectMyChannelClaims(state), + hasChannels: selectHasChannels(state), playingUri: selectPlayingUri(state), stakedLevel: selectTotalStakedAmountForChannelUri(state, props.authorUri), linkedCommentAncestors: selectLinkedCommentAncestors(state), diff --git a/ui/component/comment/view.jsx b/ui/component/comment/view.jsx index 85c7f980d..13a997128 100644 --- a/ui/component/comment/view.jsx +++ b/ui/component/comment/view.jsx @@ -47,7 +47,7 @@ type Props = { commentModBlock: (string) => void, linkedCommentId?: string, linkedCommentAncestors: { [string]: Array }, - myChannels: ?Array, + hasChannels: boolean, commentingEnabled: boolean, doToast: ({ message: string }) => void, isTopLevel?: boolean, @@ -92,7 +92,7 @@ function Comment(props: Props) { linkedCommentId, linkedCommentAncestors, commentingEnabled, - myChannels, + hasChannels, doToast, isTopLevel, threadDepth, @@ -125,7 +125,6 @@ function Comment(props: Props) { const [page, setPage] = useState(0); const [advancedEditor] = usePersistedState('comment-editor-mode', false); const [displayDeadComment, setDisplayDeadComment] = React.useState(false); - const hasChannels = myChannels && myChannels.length > 0; const likesCount = (othersReacts && othersReacts.like) || 0; const dislikesCount = (othersReacts && othersReacts.dislike) || 0; const totalLikesAndDislikes = likesCount + dislikesCount; diff --git a/ui/component/fileActions/view.jsx b/ui/component/fileActions/view.jsx index f2c9aeb63..f0e1778c5 100644 --- a/ui/component/fileActions/view.jsx +++ b/ui/component/fileActions/view.jsx @@ -27,7 +27,7 @@ type Props = { fileInfo: FileListItem, costInfo: ?{ cost: number }, renderMode: string, - myChannels: ?Array, + hasChannels: boolean, hideRepost?: boolean, reactionsDisabled: boolean, download: (string) => void, @@ -44,7 +44,7 @@ function FileActions(props: Props) { costInfo, renderMode, prepareEdit, - myChannels, + hasChannels, hideRepost, reactionsDisabled, } = props; @@ -55,7 +55,6 @@ function FileActions(props: Props) { const isMobile = useIsMobile(); 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 hasChannels = myChannels && myChannels.length > 0; const claimId = claim && claim.claim_id; const { signing_channel: signingChannel } = claim; const channelName = signingChannel && signingChannel.name; @@ -84,9 +83,7 @@ function FileActions(props: Props) { {ENABLE_FILE_REACTIONS && !reactionsDisabled && } - {!hideRepost && ( - - )} + {!hideRepost && }