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

View file

@ -35,7 +35,7 @@ type Props = {
uri: string,
claim: ?Claim,
claimIsMine: boolean,
myChannels: ?Array<ChannelClaim>,
myChannelIds: ?Array<string>,
isFetchingComments: boolean,
isFetchingCommentsById: boolean,
isFetchingReacts: boolean,
@ -64,7 +64,7 @@ function CommentList(props: Props) {
topLevelTotalPages,
claim,
claimIsMine,
myChannels,
myChannelIds,
isFetchingComments,
isFetchingReacts,
linkedCommentId,
@ -256,9 +256,7 @@ function CommentList(props: Props) {
message={comment.comment}
timePosted={comment.timestamp * 1000}
claimIsMine={claimIsMine}
commentIsMine={
comment.channel_id && myChannels && myChannels.some(({ claim_id }) => claim_id === comment.channel_id)
}
commentIsMine={comment.channel_id && myChannelIds && myChannelIds.includes(comment.channel_id)}
linkedCommentId={linkedCommentId}
isPinned={comment.is_pinned}
supportAmount={comment.support_amount}

View file

@ -1,5 +1,5 @@
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 { doCommentList, doSuperChatList } from 'redux/actions/comments';
import {
@ -20,7 +20,7 @@ const select = (state, props) => ({
fetchingComments: selectIsFetchingComments(state),
superChats: selectSuperChatsForUri(state, props.uri),
superChatsTotalAmount: selectSuperChatTotalAmountForUri(state, props.uri),
myChannels: selectMyChannelClaims(state),
myChannelIds: selectMyClaimIdsRaw(state),
});
export default connect(select, {

View file

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