2020-06-23 19:38:18 +02:00
|
|
|
// @flow
|
|
|
|
import { createSelector } from 'reselect';
|
2021-03-03 19:50:16 +01:00
|
|
|
import { selectMutedChannels } from 'redux/selectors/blocked';
|
2021-03-31 22:55:26 +02:00
|
|
|
import { selectShowMatureContent } from 'redux/selectors/settings';
|
2020-08-24 19:35:21 +02:00
|
|
|
import { selectBlacklistedOutpointMap, selectFilteredOutpointMap } from 'lbryinc';
|
2021-07-29 16:53:36 +02:00
|
|
|
import { selectClaimsById, isClaimNsfw, selectMyActiveClaims } from 'lbry-redux';
|
2020-06-23 19:38:18 +02:00
|
|
|
|
2021-03-03 19:50:16 +01:00
|
|
|
const selectState = (state) => state.comments || {};
|
|
|
|
|
|
|
|
export const selectCommentsById = createSelector(selectState, (state) => state.commentById || {});
|
|
|
|
export const selectIsFetchingComments = createSelector(selectState, (state) => state.isLoading);
|
2021-07-15 16:43:28 +02:00
|
|
|
export const selectIsFetchingCommentsByParentId = createSelector(selectState, (state) => state.isLoadingByParentId);
|
2021-03-03 19:50:16 +01:00
|
|
|
export const selectIsPostingComment = createSelector(selectState, (state) => state.isCommenting);
|
|
|
|
export const selectIsFetchingReacts = createSelector(selectState, (state) => state.isFetchingReacts);
|
|
|
|
export const selectOthersReactsById = createSelector(selectState, (state) => state.othersReactsByCommentId);
|
2021-08-17 18:09:55 +02:00
|
|
|
|
2021-08-09 08:26:03 +02:00
|
|
|
export const selectPinnedCommentsById = createSelector(selectState, (state) => state.pinnedCommentsById);
|
2021-08-17 18:09:55 +02:00
|
|
|
export const makeSelectPinnedCommentsForUri = (uri: string) =>
|
|
|
|
createSelector(
|
|
|
|
selectCommentsByUri,
|
|
|
|
selectCommentsById,
|
|
|
|
selectPinnedCommentsById,
|
|
|
|
(byUri, byId, pinnedCommentsById) => {
|
|
|
|
const claimId = byUri[uri];
|
|
|
|
const pinnedCommentIds = pinnedCommentsById && pinnedCommentsById[claimId];
|
|
|
|
const pinnedComments = [];
|
|
|
|
|
|
|
|
if (pinnedCommentIds) {
|
|
|
|
pinnedCommentIds.forEach((commentId) => {
|
|
|
|
pinnedComments.push(byId[commentId]);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
return pinnedComments;
|
|
|
|
}
|
|
|
|
);
|
2021-05-25 08:17:36 +02:00
|
|
|
|
2021-03-03 19:50:16 +01:00
|
|
|
export const selectModerationBlockList = createSelector(selectState, (state) =>
|
|
|
|
state.moderationBlockList ? state.moderationBlockList.reverse() : []
|
|
|
|
);
|
2021-05-25 08:17:36 +02:00
|
|
|
export const selectAdminBlockList = createSelector(selectState, (state) =>
|
|
|
|
state.adminBlockList ? state.adminBlockList.reverse() : []
|
|
|
|
);
|
|
|
|
export const selectModeratorBlockList = createSelector(selectState, (state) =>
|
|
|
|
state.moderatorBlockList ? state.moderatorBlockList.reverse() : []
|
|
|
|
);
|
|
|
|
|
2021-08-20 09:18:54 +02:00
|
|
|
export const selectPersonalTimeoutMap = createSelector(selectState, (state) => state.personalTimeoutMap);
|
|
|
|
export const selectAdminTimeoutMap = createSelector(selectState, (state) => state.adminTimeoutMap);
|
|
|
|
export const selectModeratorTimeoutMap = createSelector(selectState, (state) => state.moderatorTimeoutMap);
|
|
|
|
|
2021-05-25 08:17:36 +02:00
|
|
|
export const selectModeratorBlockListDelegatorsMap = createSelector(
|
|
|
|
selectState,
|
|
|
|
(state) => state.moderatorBlockListDelegatorsMap
|
|
|
|
);
|
|
|
|
|
|
|
|
export const selectTogglingForDelegatorMap = createSelector(selectState, (state) => state.togglingForDelegatorMap);
|
|
|
|
|
2021-03-03 19:50:16 +01:00
|
|
|
export const selectBlockingByUri = createSelector(selectState, (state) => state.blockingByUri);
|
|
|
|
export const selectUnBlockingByUri = createSelector(selectState, (state) => state.unBlockingByUri);
|
|
|
|
export const selectFetchingModerationBlockList = createSelector(
|
|
|
|
selectState,
|
|
|
|
(state) => state.fetchingModerationBlockList
|
|
|
|
);
|
2020-10-06 21:35:13 +02:00
|
|
|
|
2021-05-25 08:17:36 +02:00
|
|
|
export const selectModerationDelegatesById = createSelector(selectState, (state) => state.moderationDelegatesById);
|
|
|
|
export const selectIsFetchingModerationDelegates = createSelector(
|
|
|
|
selectState,
|
|
|
|
(state) => state.fetchingModerationDelegates
|
|
|
|
);
|
|
|
|
|
|
|
|
export const selectModerationDelegatorsById = createSelector(selectState, (state) => state.moderationDelegatorsById);
|
|
|
|
export const selectIsFetchingModerationDelegators = createSelector(
|
|
|
|
selectState,
|
|
|
|
(state) => state.fetchingModerationDelegators
|
|
|
|
);
|
|
|
|
|
|
|
|
export const selectHasAdminChannel = createSelector(selectState, (state) => {
|
|
|
|
const myChannelIds = Object.keys(state.moderationDelegatorsById);
|
|
|
|
for (let i = 0; i < myChannelIds.length; ++i) {
|
|
|
|
const id = myChannelIds[i];
|
|
|
|
if (state.moderationDelegatorsById[id] && state.moderationDelegatorsById[id].global) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
|
|
|
|
/// Lint doesn't like this:
|
|
|
|
// return Object.values(state.moderationDelegatorsById).some((x) => x.global);
|
|
|
|
});
|
|
|
|
|
2020-06-23 19:38:18 +02:00
|
|
|
export const selectCommentsByClaimId = createSelector(selectState, selectCommentsById, (state, byId) => {
|
|
|
|
const byClaimId = state.byId || {};
|
|
|
|
const comments = {};
|
|
|
|
|
2020-08-24 19:35:21 +02:00
|
|
|
// replace every comment_id in the list with the actual comment object
|
|
|
|
Object.keys(byClaimId).forEach((claimId: string) => {
|
|
|
|
const commentIds = byClaimId[claimId];
|
|
|
|
|
|
|
|
comments[claimId] = Array(commentIds === null ? 0 : commentIds.length);
|
|
|
|
for (let i = 0; i < commentIds.length; i++) {
|
|
|
|
comments[claimId][i] = byId[commentIds[i]];
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
return comments;
|
|
|
|
});
|
|
|
|
|
2021-04-23 21:59:48 +02:00
|
|
|
export const selectSuperchatsByUri = createSelector(selectState, (state) => state.superChatsByUri);
|
|
|
|
|
2020-08-24 19:35:21 +02:00
|
|
|
export const selectTopLevelCommentsByClaimId = createSelector(selectState, selectCommentsById, (state, byId) => {
|
|
|
|
const byClaimId = state.topLevelCommentsById || {};
|
|
|
|
const comments = {};
|
|
|
|
|
2020-06-23 19:38:18 +02:00
|
|
|
// replace every comment_id in the list with the actual comment object
|
2021-03-03 19:50:16 +01:00
|
|
|
Object.keys(byClaimId).forEach((claimId) => {
|
2020-06-23 19:38:18 +02:00
|
|
|
const commentIds = byClaimId[claimId];
|
|
|
|
|
|
|
|
comments[claimId] = Array(commentIds === null ? 0 : commentIds.length);
|
|
|
|
for (let i = 0; i < commentIds.length; i++) {
|
|
|
|
comments[claimId][i] = byId[commentIds[i]];
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
return comments;
|
|
|
|
});
|
|
|
|
|
2020-08-24 19:35:21 +02:00
|
|
|
export const makeSelectCommentForCommentId = (commentId: string) =>
|
2021-03-03 19:50:16 +01:00
|
|
|
createSelector(selectCommentsById, (comments) => comments[commentId]);
|
2020-08-24 19:35:21 +02:00
|
|
|
|
|
|
|
export const selectRepliesByParentId = createSelector(selectState, selectCommentsById, (state, byId) => {
|
|
|
|
const byParentId = state.repliesByParentId || {};
|
|
|
|
const comments = {};
|
|
|
|
|
|
|
|
// replace every comment_id in the list with the actual comment object
|
2021-03-03 19:50:16 +01:00
|
|
|
Object.keys(byParentId).forEach((id) => {
|
2020-08-24 19:35:21 +02:00
|
|
|
const commentIds = byParentId[id];
|
|
|
|
|
|
|
|
comments[id] = Array(commentIds === null ? 0 : commentIds.length);
|
|
|
|
for (let i = 0; i < commentIds.length; i++) {
|
|
|
|
comments[id][i] = byId[commentIds[i]];
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
return comments;
|
|
|
|
});
|
|
|
|
|
2020-06-23 19:38:18 +02:00
|
|
|
// previously this used a mapping from claimId -> Array<Comments>
|
|
|
|
/* export const selectCommentsById = createSelector(
|
|
|
|
selectState,
|
|
|
|
state => state.byId || {}
|
|
|
|
); */
|
2021-03-03 19:50:16 +01:00
|
|
|
export const selectCommentsByUri = createSelector(selectState, (state) => {
|
2020-06-23 19:38:18 +02:00
|
|
|
const byUri = state.commentsByUri || {};
|
|
|
|
const comments = {};
|
2021-03-03 19:50:16 +01:00
|
|
|
Object.keys(byUri).forEach((uri) => {
|
2020-06-23 19:38:18 +02:00
|
|
|
const claimId = byUri[uri];
|
|
|
|
if (claimId === null) {
|
|
|
|
comments[uri] = null;
|
|
|
|
} else {
|
|
|
|
comments[uri] = claimId;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
return comments;
|
|
|
|
});
|
|
|
|
|
2021-07-15 16:43:28 +02:00
|
|
|
export const selectLinkedCommentAncestors = createSelector(selectState, (state) => state.linkedCommentAncestors);
|
|
|
|
|
2020-09-29 16:10:23 +02:00
|
|
|
export const makeSelectCommentIdsForUri = (uri: string) =>
|
|
|
|
createSelector(selectState, selectCommentsByUri, selectClaimsById, (state, byUri) => {
|
|
|
|
const claimId = byUri[uri];
|
|
|
|
return state.byId[claimId];
|
|
|
|
});
|
|
|
|
|
2021-07-15 16:43:28 +02:00
|
|
|
export const selectMyReactionsByCommentId = createSelector(selectState, (state) => state.myReactsByCommentId);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* makeSelectMyReactionsForComment
|
|
|
|
*
|
|
|
|
* @param commentIdChannelId Format = "commentId:MyChannelId".
|
|
|
|
*/
|
|
|
|
export const makeSelectMyReactionsForComment = (commentIdChannelId: string) =>
|
2021-03-03 19:50:16 +01:00
|
|
|
createSelector(selectState, (state) => {
|
2021-03-24 03:53:33 +01:00
|
|
|
if (!state.myReactsByCommentId) {
|
|
|
|
return [];
|
|
|
|
}
|
|
|
|
|
2021-07-15 16:43:28 +02:00
|
|
|
return state.myReactsByCommentId[commentIdChannelId] || [];
|
2020-09-29 16:10:23 +02:00
|
|
|
});
|
|
|
|
|
|
|
|
export const makeSelectOthersReactionsForComment = (commentId: string) =>
|
2021-03-03 19:50:16 +01:00
|
|
|
createSelector(selectState, (state) => {
|
2021-03-24 03:53:33 +01:00
|
|
|
if (!state.othersReactsByCommentId) {
|
|
|
|
return {};
|
|
|
|
}
|
|
|
|
|
|
|
|
return state.othersReactsByCommentId[commentId] || {};
|
2020-09-29 16:10:23 +02:00
|
|
|
});
|
|
|
|
|
2021-03-03 19:50:16 +01:00
|
|
|
export const selectPendingCommentReacts = createSelector(selectState, (state) => state.pendingCommentReactions);
|
2020-09-29 20:45:28 +02:00
|
|
|
|
2021-04-20 10:40:53 +02:00
|
|
|
export const selectSettingsByChannelId = createSelector(selectState, (state) => state.settingsByChannelId);
|
|
|
|
|
|
|
|
export const selectFetchingCreatorSettings = createSelector(selectState, (state) => state.fetchingSettings);
|
|
|
|
|
|
|
|
export const selectFetchingBlockedWords = createSelector(selectState, (state) => state.fetchingBlockedWords);
|
|
|
|
|
2020-06-23 19:38:18 +02:00
|
|
|
export const makeSelectCommentsForUri = (uri: string) =>
|
2020-07-15 18:15:00 +02:00
|
|
|
createSelector(
|
2021-08-04 15:40:16 +02:00
|
|
|
(state) => state,
|
2020-07-15 18:15:00 +02:00
|
|
|
selectCommentsByClaimId,
|
|
|
|
selectCommentsByUri,
|
2021-08-04 15:40:16 +02:00
|
|
|
(state, byClaimId, byUri) => {
|
2020-07-15 18:15:00 +02:00
|
|
|
const claimId = byUri[uri];
|
|
|
|
const comments = byClaimId && byClaimId[claimId];
|
Run the extra app-side comment filter only if the claim is not ours.
## Preamble
- The app-side uses a cached blocklist, so when a Timeout expires, it doesn't know that the ban has been lifted.
- Meanwhile, we are doing extra comment filtering using this blocklist (so that we don't see comments that we have blocked, regardless of whose claim we are viewing).
## Issue
In a livestream, if a new message from an ex-offender comes in after their ban has been lifted, we do get the websocket message but it's being filtered out locally as mentioned above. So, the msg ended up being visible for everyone except the owner.
## Fix (band aid)
- Don't run the extra filter if the claim we are viewing is ours -- commentron would have filtered it for us anyways, and is the right logic to use even before this Timeout feature is introduced.
- For the case of Timeout, this only serves as a band-aid until Commentron Issue 80 is available for us to detect the ban has been lifted. This is because it doesn't handle the case where I am a viewer and I decided to timeout someone for a few minutes. Because I am not the owner of the claim, the offender will continue to be blocked due to the same issue mentioned above.
2021-09-03 09:43:01 +02:00
|
|
|
return makeSelectFilteredComments(comments, claimId)(state);
|
2020-08-24 19:35:21 +02:00
|
|
|
}
|
|
|
|
);
|
|
|
|
|
|
|
|
export const makeSelectTopLevelCommentsForUri = (uri: string) =>
|
|
|
|
createSelector(
|
2021-08-04 15:40:16 +02:00
|
|
|
(state) => state,
|
2020-08-24 19:35:21 +02:00
|
|
|
selectTopLevelCommentsByClaimId,
|
|
|
|
selectCommentsByUri,
|
2021-08-04 15:40:16 +02:00
|
|
|
(state, byClaimId, byUri) => {
|
2020-08-24 19:35:21 +02:00
|
|
|
const claimId = byUri[uri];
|
|
|
|
const comments = byClaimId && byClaimId[claimId];
|
Run the extra app-side comment filter only if the claim is not ours.
## Preamble
- The app-side uses a cached blocklist, so when a Timeout expires, it doesn't know that the ban has been lifted.
- Meanwhile, we are doing extra comment filtering using this blocklist (so that we don't see comments that we have blocked, regardless of whose claim we are viewing).
## Issue
In a livestream, if a new message from an ex-offender comes in after their ban has been lifted, we do get the websocket message but it's being filtered out locally as mentioned above. So, the msg ended up being visible for everyone except the owner.
## Fix (band aid)
- Don't run the extra filter if the claim we are viewing is ours -- commentron would have filtered it for us anyways, and is the right logic to use even before this Timeout feature is introduced.
- For the case of Timeout, this only serves as a band-aid until Commentron Issue 80 is available for us to detect the ban has been lifted. This is because it doesn't handle the case where I am a viewer and I decided to timeout someone for a few minutes. Because I am not the owner of the claim, the offender will continue to be blocked due to the same issue mentioned above.
2021-09-03 09:43:01 +02:00
|
|
|
return makeSelectFilteredComments(comments, claimId)(state);
|
2020-08-24 19:35:21 +02:00
|
|
|
}
|
|
|
|
);
|
|
|
|
|
2021-07-15 16:43:28 +02:00
|
|
|
export const makeSelectTopLevelTotalCommentsForUri = (uri: string) =>
|
|
|
|
createSelector(selectState, selectCommentsByUri, (state, byUri) => {
|
|
|
|
const claimId = byUri[uri];
|
|
|
|
return state.topLevelTotalCommentsById[claimId] || 0;
|
|
|
|
});
|
|
|
|
|
|
|
|
export const makeSelectTopLevelTotalPagesForUri = (uri: string) =>
|
|
|
|
createSelector(selectState, selectCommentsByUri, (state, byUri) => {
|
|
|
|
const claimId = byUri[uri];
|
|
|
|
return state.topLevelTotalPagesById[claimId] || 0;
|
|
|
|
});
|
|
|
|
|
2020-08-24 19:35:21 +02:00
|
|
|
export const makeSelectRepliesForParentId = (id: string) =>
|
|
|
|
createSelector(
|
2021-08-04 15:40:16 +02:00
|
|
|
(state) => state,
|
2020-08-24 19:35:21 +02:00
|
|
|
selectCommentsById,
|
2021-08-04 15:40:16 +02:00
|
|
|
(state, commentsById) => {
|
2020-08-24 19:35:21 +02:00
|
|
|
// const claimId = byUri[uri]; // just parentId (id)
|
2021-08-04 15:40:16 +02:00
|
|
|
const replyIdsByParentId = state.comments.repliesByParentId;
|
2020-08-24 19:35:21 +02:00
|
|
|
const replyIdsForParent = replyIdsByParentId[id] || [];
|
|
|
|
if (!replyIdsForParent.length) return null;
|
|
|
|
|
|
|
|
const comments = [];
|
2021-03-03 19:50:16 +01:00
|
|
|
replyIdsForParent.forEach((cid) => {
|
2020-08-24 19:35:21 +02:00
|
|
|
comments.push(commentsById[cid]);
|
|
|
|
});
|
|
|
|
// const comments = byParentId && byParentId[id];
|
2020-07-15 20:07:07 +02:00
|
|
|
|
2021-08-04 15:40:16 +02:00
|
|
|
return makeSelectFilteredComments(comments)(state);
|
|
|
|
}
|
|
|
|
);
|
|
|
|
|
Run the extra app-side comment filter only if the claim is not ours.
## Preamble
- The app-side uses a cached blocklist, so when a Timeout expires, it doesn't know that the ban has been lifted.
- Meanwhile, we are doing extra comment filtering using this blocklist (so that we don't see comments that we have blocked, regardless of whose claim we are viewing).
## Issue
In a livestream, if a new message from an ex-offender comes in after their ban has been lifted, we do get the websocket message but it's being filtered out locally as mentioned above. So, the msg ended up being visible for everyone except the owner.
## Fix (band aid)
- Don't run the extra filter if the claim we are viewing is ours -- commentron would have filtered it for us anyways, and is the right logic to use even before this Timeout feature is introduced.
- For the case of Timeout, this only serves as a band-aid until Commentron Issue 80 is available for us to detect the ban has been lifted. This is because it doesn't handle the case where I am a viewer and I decided to timeout someone for a few minutes. Because I am not the owner of the claim, the offender will continue to be blocked due to the same issue mentioned above.
2021-09-03 09:43:01 +02:00
|
|
|
/**
|
|
|
|
* makeSelectFilteredComments
|
|
|
|
*
|
|
|
|
* @param comments List of comments to filter.
|
|
|
|
* @param claimId The claim that `comments` reside in.
|
|
|
|
*/
|
|
|
|
const makeSelectFilteredComments = (comments: Array<Comment>, claimId?: string) =>
|
2021-08-04 15:40:16 +02:00
|
|
|
createSelector(
|
|
|
|
selectClaimsById,
|
|
|
|
selectMyActiveClaims,
|
|
|
|
selectMutedChannels,
|
|
|
|
selectModerationBlockList,
|
|
|
|
selectAdminBlockList,
|
|
|
|
selectModeratorBlockList,
|
|
|
|
selectBlacklistedOutpointMap,
|
|
|
|
selectFilteredOutpointMap,
|
|
|
|
selectShowMatureContent,
|
|
|
|
(
|
|
|
|
claimsById,
|
|
|
|
myClaims,
|
|
|
|
mutedChannels,
|
|
|
|
personalBlockList,
|
|
|
|
adminBlockList,
|
|
|
|
moderatorBlockList,
|
|
|
|
blacklistedMap,
|
|
|
|
filteredMap,
|
|
|
|
showMatureContent
|
|
|
|
) => {
|
2020-07-15 20:07:07 +02:00
|
|
|
return comments
|
2021-03-03 19:50:16 +01:00
|
|
|
? comments.filter((comment) => {
|
2020-09-11 19:51:31 +02:00
|
|
|
if (!comment) {
|
2021-08-04 15:40:16 +02:00
|
|
|
// It may have been recently deleted after being blocked
|
2020-09-11 19:51:31 +02:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2020-07-15 20:07:07 +02:00
|
|
|
const channelClaim = claimsById[comment.channel_id];
|
|
|
|
|
|
|
|
// Return comment if `channelClaim` doesn't exist so the component knows to resolve the author
|
|
|
|
if (channelClaim) {
|
2020-07-20 19:19:45 +02:00
|
|
|
if (myClaims && myClaims.size > 0) {
|
2020-07-15 20:50:45 +02:00
|
|
|
const claimIsMine = channelClaim.is_my_output || myClaims.has(channelClaim.claim_id);
|
|
|
|
if (claimIsMine) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-07-15 20:07:07 +02:00
|
|
|
const outpoint = `${channelClaim.txid}:${channelClaim.nout}`;
|
2020-07-20 19:19:45 +02:00
|
|
|
if (blacklistedMap[outpoint] || filteredMap[outpoint]) {
|
2020-07-15 20:07:07 +02:00
|
|
|
return false;
|
|
|
|
}
|
2020-07-15 20:50:45 +02:00
|
|
|
|
|
|
|
if (!showMatureContent) {
|
|
|
|
const claimIsMature = isClaimNsfw(channelClaim);
|
|
|
|
if (claimIsMature) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
2020-07-15 20:07:07 +02:00
|
|
|
}
|
|
|
|
|
Run the extra app-side comment filter only if the claim is not ours.
## Preamble
- The app-side uses a cached blocklist, so when a Timeout expires, it doesn't know that the ban has been lifted.
- Meanwhile, we are doing extra comment filtering using this blocklist (so that we don't see comments that we have blocked, regardless of whose claim we are viewing).
## Issue
In a livestream, if a new message from an ex-offender comes in after their ban has been lifted, we do get the websocket message but it's being filtered out locally as mentioned above. So, the msg ended up being visible for everyone except the owner.
## Fix (band aid)
- Don't run the extra filter if the claim we are viewing is ours -- commentron would have filtered it for us anyways, and is the right logic to use even before this Timeout feature is introduced.
- For the case of Timeout, this only serves as a band-aid until Commentron Issue 80 is available for us to detect the ban has been lifted. This is because it doesn't handle the case where I am a viewer and I decided to timeout someone for a few minutes. Because I am not the owner of the claim, the offender will continue to be blocked due to the same issue mentioned above.
2021-09-03 09:43:01 +02:00
|
|
|
if (claimId) {
|
|
|
|
const claimIdIsMine = myClaims && myClaims.size > 0 && myClaims.has(claimId);
|
|
|
|
if (!claimIdIsMine) {
|
2021-09-03 17:33:04 +02:00
|
|
|
if (personalBlockList.includes(comment.channel_url) || adminBlockList.includes(comment.channel_url)) {
|
2021-09-03 17:28:09 +02:00
|
|
|
return false;
|
|
|
|
}
|
Run the extra app-side comment filter only if the claim is not ours.
## Preamble
- The app-side uses a cached blocklist, so when a Timeout expires, it doesn't know that the ban has been lifted.
- Meanwhile, we are doing extra comment filtering using this blocklist (so that we don't see comments that we have blocked, regardless of whose claim we are viewing).
## Issue
In a livestream, if a new message from an ex-offender comes in after their ban has been lifted, we do get the websocket message but it's being filtered out locally as mentioned above. So, the msg ended up being visible for everyone except the owner.
## Fix (band aid)
- Don't run the extra filter if the claim we are viewing is ours -- commentron would have filtered it for us anyways, and is the right logic to use even before this Timeout feature is introduced.
- For the case of Timeout, this only serves as a band-aid until Commentron Issue 80 is available for us to detect the ban has been lifted. This is because it doesn't handle the case where I am a viewer and I decided to timeout someone for a few minutes. Because I am not the owner of the claim, the offender will continue to be blocked due to the same issue mentioned above.
2021-09-03 09:43:01 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return !mutedChannels.includes(comment.channel_url);
|
2020-07-15 20:07:07 +02:00
|
|
|
})
|
|
|
|
: [];
|
2020-07-15 18:15:00 +02:00
|
|
|
}
|
|
|
|
);
|
2020-09-30 20:46:17 +02:00
|
|
|
|
2021-08-04 17:01:31 +02:00
|
|
|
export const makeSelectTotalReplyPagesForParentId = (parentId: string) =>
|
2021-07-15 16:43:28 +02:00
|
|
|
createSelector(selectState, (state) => {
|
2021-08-04 17:01:31 +02:00
|
|
|
return state.repliesTotalPagesByParentId[parentId] || 0;
|
2021-07-15 16:43:28 +02:00
|
|
|
});
|
|
|
|
|
2020-09-30 20:46:17 +02:00
|
|
|
export const makeSelectTotalCommentsCountForUri = (uri: string) =>
|
2021-07-15 16:43:28 +02:00
|
|
|
createSelector(selectState, selectCommentsByUri, (state, byUri) => {
|
|
|
|
const claimId = byUri[uri];
|
|
|
|
return state.totalCommentsById[claimId] || 0;
|
2020-09-30 20:46:17 +02:00
|
|
|
});
|
2021-03-03 19:50:16 +01:00
|
|
|
|
2021-05-25 08:17:36 +02:00
|
|
|
// Personal list
|
2021-03-03 19:50:16 +01:00
|
|
|
export const makeSelectChannelIsBlocked = (uri: string) =>
|
|
|
|
createSelector(selectModerationBlockList, (blockedChannelUris) => {
|
|
|
|
if (!blockedChannelUris || !blockedChannelUris) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
return blockedChannelUris.includes(uri);
|
|
|
|
});
|
|
|
|
|
2021-05-25 08:17:36 +02:00
|
|
|
export const makeSelectChannelIsAdminBlocked = (uri: string) =>
|
|
|
|
createSelector(selectAdminBlockList, (list) => {
|
|
|
|
return list ? list.includes(uri) : false;
|
|
|
|
});
|
|
|
|
|
|
|
|
export const makeSelectChannelIsModeratorBlocked = (uri: string) =>
|
|
|
|
createSelector(selectModeratorBlockList, (list) => {
|
|
|
|
return list ? list.includes(uri) : false;
|
|
|
|
});
|
|
|
|
|
|
|
|
export const makeSelectChannelIsModeratorBlockedForCreator = (uri: string, creatorUri: string) =>
|
|
|
|
createSelector(selectModeratorBlockList, selectModeratorBlockListDelegatorsMap, (blockList, delegatorsMap) => {
|
|
|
|
if (!blockList) return false;
|
|
|
|
return blockList.includes(uri) && delegatorsMap[uri] && delegatorsMap[uri].includes(creatorUri);
|
|
|
|
});
|
|
|
|
|
|
|
|
export const makeSelectIsTogglingForDelegator = (uri: string, creatorUri: string) =>
|
|
|
|
createSelector(selectTogglingForDelegatorMap, (togglingForDelegatorMap) => {
|
|
|
|
return togglingForDelegatorMap[uri] && togglingForDelegatorMap[uri].includes(creatorUri);
|
|
|
|
});
|
|
|
|
|
2021-03-03 19:50:16 +01:00
|
|
|
export const makeSelectUriIsBlockingOrUnBlocking = (uri: string) =>
|
|
|
|
createSelector(selectBlockingByUri, selectUnBlockingByUri, (blockingByUri, unBlockingByUri) => {
|
|
|
|
return blockingByUri[uri] || unBlockingByUri[uri];
|
|
|
|
});
|
2021-04-23 21:59:48 +02:00
|
|
|
|
|
|
|
export const makeSelectSuperChatDataForUri = (uri: string) =>
|
|
|
|
createSelector(selectSuperchatsByUri, (byUri) => {
|
|
|
|
return byUri[uri];
|
|
|
|
});
|
|
|
|
|
|
|
|
export const makeSelectSuperChatsForUri = (uri: string) =>
|
|
|
|
createSelector(makeSelectSuperChatDataForUri(uri), (superChatData) => {
|
|
|
|
if (!superChatData) {
|
|
|
|
return undefined;
|
|
|
|
}
|
|
|
|
|
|
|
|
return superChatData.comments;
|
|
|
|
});
|
|
|
|
|
|
|
|
export const makeSelectSuperChatTotalAmountForUri = (uri: string) =>
|
|
|
|
createSelector(makeSelectSuperChatDataForUri(uri), (superChatData) => {
|
|
|
|
if (!superChatData) {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
return superChatData.totalAmount;
|
|
|
|
});
|