Comments: use the lighter selectMyClaimIdsRaw

`selectMyActiveClaims` includes pending claims, so it gets invalidated often.

For the case of comment-filtering, we don't care about pending or abandoned own claims.
This commit is contained in:
infinite-persistence 2021-11-04 13:26:11 +08:00
parent 61a2ed2583
commit a65e68d023
No known key found for this signature in database
GPG key ID: B9C3252EDC3D0AA0
4 changed files with 10 additions and 19 deletions

View file

@ -4,7 +4,7 @@ import {
makeSelectClaimForUri, makeSelectClaimForUri,
makeSelectClaimIsMine, makeSelectClaimIsMine,
selectFetchingMyChannels, selectFetchingMyChannels,
selectMyChannelClaims, selectMyClaimIdsRaw,
} from 'redux/selectors/claims'; } from 'redux/selectors/claims';
import { import {
selectTopLevelCommentsForUri, selectTopLevelCommentsForUri,
@ -35,7 +35,7 @@ const select = (state, props) => {
return { return {
topLevelComments, topLevelComments,
resolvedComments, resolvedComments,
myChannels: selectMyChannelClaims(state), myChannelIds: selectMyClaimIdsRaw(state),
allCommentIds: makeSelectCommentIdsForUri(props.uri)(state), allCommentIds: makeSelectCommentIdsForUri(props.uri)(state),
pinnedComments: selectPinnedCommentsForUri(state, props.uri), pinnedComments: selectPinnedCommentsForUri(state, props.uri),
topLevelTotalPages: makeSelectTopLevelTotalPagesForUri(props.uri)(state), topLevelTotalPages: makeSelectTopLevelTotalPagesForUri(props.uri)(state),

View file

@ -35,7 +35,7 @@ type Props = {
uri: string, uri: string,
claim: ?Claim, claim: ?Claim,
claimIsMine: boolean, claimIsMine: boolean,
myChannels: ?Array<ChannelClaim>, myChannelIds: ?Array<string>,
isFetchingComments: boolean, isFetchingComments: boolean,
isFetchingCommentsById: boolean, isFetchingCommentsById: boolean,
isFetchingReacts: boolean, isFetchingReacts: boolean,
@ -64,7 +64,7 @@ function CommentList(props: Props) {
topLevelTotalPages, topLevelTotalPages,
claim, claim,
claimIsMine, claimIsMine,
myChannels, myChannelIds,
isFetchingComments, isFetchingComments,
isFetchingReacts, isFetchingReacts,
linkedCommentId, linkedCommentId,
@ -256,9 +256,7 @@ function CommentList(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}
isPinned={comment.is_pinned} isPinned={comment.is_pinned}
supportAmount={comment.support_amount} supportAmount={comment.support_amount}

View file

@ -1,5 +1,5 @@
import { connect } from 'react-redux'; import { connect } from 'react-redux';
import { selectClaimForUri, selectMyChannelClaims } from 'redux/selectors/claims'; import { selectClaimForUri, selectMyClaimIdsRaw } from 'redux/selectors/claims';
import { doCommentSocketConnect, doCommentSocketDisconnect } from 'redux/actions/websocket'; import { doCommentSocketConnect, doCommentSocketDisconnect } from 'redux/actions/websocket';
import { doCommentList, doSuperChatList } from 'redux/actions/comments'; import { doCommentList, doSuperChatList } from 'redux/actions/comments';
import { import {
@ -20,7 +20,7 @@ const select = (state, props) => ({
fetchingComments: selectIsFetchingComments(state), fetchingComments: selectIsFetchingComments(state),
superChats: selectSuperChatsForUri(state, props.uri), superChats: selectSuperChatsForUri(state, props.uri),
superChatsTotalAmount: selectSuperChatTotalAmountForUri(state, props.uri), superChatsTotalAmount: selectSuperChatTotalAmountForUri(state, props.uri),
myChannels: selectMyChannelClaims(state), myChannelIds: selectMyClaimIdsRaw(state),
}); });
export default connect(select, { export default connect(select, {

View file

@ -26,7 +26,7 @@ type Props = {
fetchingComments: boolean, fetchingComments: boolean,
doSuperChatList: (string) => void, doSuperChatList: (string) => void,
superChats: Array<Comment>, superChats: Array<Comment>,
myChannels: ?Array<ChannelClaim>, myChannelIds: ?Array<string>,
}; };
const VIEW_MODE_CHAT = 'view_chat'; const VIEW_MODE_CHAT = 'view_chat';
@ -45,7 +45,7 @@ export default function LivestreamComments(props: Props) {
doCommentList, doCommentList,
fetchingComments, fetchingComments,
doSuperChatList, doSuperChatList,
myChannels, myChannelIds,
superChats: superChatsByTipAmount, superChats: superChatsByTipAmount,
} = props; } = props;
@ -152,14 +152,7 @@ export default function LivestreamComments(props: Props) {
// todo: implement comment_list --mine in SDK so redux can grab with selectCommentIsMine // todo: implement comment_list --mine in SDK so redux can grab with selectCommentIsMine
function isMyComment(channelId: string) { function isMyComment(channelId: string) {
if (myChannels != null && channelId != null) { return myChannelIds ? myChannelIds.includes(channelId) : false;
for (let i = 0; i < myChannels.length; i++) {
if (myChannels[i].claim_id === channelId) {
return true;
}
}
}
return false;
} }
if (!claim) { if (!claim) {