comment react selectors
This commit is contained in:
parent
29b845c3fc
commit
e7572312a8
3 changed files with 47 additions and 72 deletions
1
flow-typed/Comment.js
vendored
1
flow-typed/Comment.js
vendored
|
@ -45,6 +45,7 @@ declare type CommentsState = {
|
||||||
isLoading: boolean,
|
isLoading: boolean,
|
||||||
isLoadingById: boolean,
|
isLoadingById: boolean,
|
||||||
isLoadingByParentId: { [string]: boolean },
|
isLoadingByParentId: { [string]: boolean },
|
||||||
|
isCommenting: boolean,
|
||||||
myComments: ?Set<string>,
|
myComments: ?Set<string>,
|
||||||
isFetchingReacts: boolean,
|
isFetchingReacts: boolean,
|
||||||
myReactsByCommentId: ?{ [string]: Array<string> }, // {"CommentId:MyChannelId": ["like", "dislike", ...]}
|
myReactsByCommentId: ?{ [string]: Array<string> }, // {"CommentId:MyChannelId": ["like", "dislike", ...]}
|
||||||
|
|
|
@ -2220,5 +2220,7 @@
|
||||||
"filtered": "filtered",
|
"filtered": "filtered",
|
||||||
"View All Playlists": "View All Playlists",
|
"View All Playlists": "View All Playlists",
|
||||||
"Your wallet is not currently using a cloud sync service. You are in control of backing up your wallet.": "Your wallet is not currently using a cloud sync service. You are in control of backing up your wallet.",
|
"Your wallet is not currently using a cloud sync service. You are in control of backing up your wallet.": "Your wallet is not currently using a cloud sync service. You are in control of backing up your wallet.",
|
||||||
|
"Sending": "Sending",
|
||||||
|
"You sent %lbc%": "You sent %lbc%",
|
||||||
"--end--": "--end--"
|
"--end--": "--end--"
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,16 +6,28 @@ import { selectBlacklistedOutpointMap, selectFilteredOutpointMap } from 'lbryinc
|
||||||
import { selectClaimsById, selectMyActiveClaims } from 'redux/selectors/claims';
|
import { selectClaimsById, selectMyActiveClaims } from 'redux/selectors/claims';
|
||||||
import { isClaimNsfw } from 'util/claim';
|
import { isClaimNsfw } from 'util/claim';
|
||||||
|
|
||||||
|
type State = { comments: CommentsState };
|
||||||
|
|
||||||
const selectState = (state) => state.comments || {};
|
const selectState = (state) => state.comments || {};
|
||||||
|
|
||||||
export const selectCommentsById = createSelector(selectState, (state) => state.commentById || {});
|
export const selectCommentsById = (state: State) => selectState(state).commentById || {};
|
||||||
export const selectIsFetchingComments = createSelector(selectState, (state) => state.isLoading);
|
export const selectIsFetchingComments = (state: State) => selectState(state).isLoading;
|
||||||
export const selectIsFetchingCommentsById = createSelector(selectState, (state) => state.isLoadingById);
|
export const selectIsFetchingCommentsById = (state: State) => selectState(state).isLoadingById;
|
||||||
export const selectIsFetchingCommentsByParentId = createSelector(selectState, (state) => state.isLoadingByParentId);
|
export const selectIsFetchingCommentsByParentId = (state: State) => selectState(state).isLoadingByParentId;
|
||||||
export const selectIsFetchingReacts = createSelector(selectState, (state) => state.isFetchingReacts);
|
export const selectIsFetchingReacts = (state: State) => selectState(state).isFetchingReacts;
|
||||||
export const selectOthersReactsById = createSelector(selectState, (state) => state.othersReactsByCommentId);
|
|
||||||
|
|
||||||
export const selectPinnedCommentsById = createSelector(selectState, (state) => state.pinnedCommentsById);
|
export const selectMyReacts = (state: State) => state.comments.myReactsByCommentId;
|
||||||
|
export const selectMyReactsForComment = (state: State, commentIdChannelId: string) => {
|
||||||
|
// @commentIdChannelId: Format = 'commentId:MyChannelId'
|
||||||
|
return state.comments.myReactsByCommentId && state.comments.myReactsByCommentId[commentIdChannelId];
|
||||||
|
};
|
||||||
|
|
||||||
|
export const selectOthersReacts = (state: State) => state.comments.othersReactsByCommentId;
|
||||||
|
export const selectOthersReactsForComment = (state: State, id: string) => {
|
||||||
|
return state.comments.othersReactsByCommentId && state.comments.othersReactsByCommentId[id];
|
||||||
|
};
|
||||||
|
|
||||||
|
export const selectPinnedCommentsById = (state: State) => selectState(state).pinnedCommentsById;
|
||||||
export const makeSelectPinnedCommentsForUri = (uri: string) =>
|
export const makeSelectPinnedCommentsForUri = (uri: string) =>
|
||||||
createSelector(
|
createSelector(
|
||||||
selectCommentsByUri,
|
selectCommentsByUri,
|
||||||
|
@ -36,8 +48,11 @@ export const makeSelectPinnedCommentsForUri = (uri: string) =>
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
export const selectModerationBlockList = createSelector(selectState, (state) =>
|
export const selectModerationBlockList = createSelector(
|
||||||
state.moderationBlockList ? state.moderationBlockList.reverse() : []
|
(state) => selectState(state).moderationBlockList,
|
||||||
|
(moderationBlockList) => {
|
||||||
|
return moderationBlockList ? moderationBlockList.reverse() : [];
|
||||||
|
}
|
||||||
);
|
);
|
||||||
export const selectAdminBlockList = createSelector(selectState, (state) =>
|
export const selectAdminBlockList = createSelector(selectState, (state) =>
|
||||||
state.adminBlockList ? state.adminBlockList.reverse() : []
|
state.adminBlockList ? state.adminBlockList.reverse() : []
|
||||||
|
@ -46,35 +61,19 @@ export const selectModeratorBlockList = createSelector(selectState, (state) =>
|
||||||
state.moderatorBlockList ? state.moderatorBlockList.reverse() : []
|
state.moderatorBlockList ? state.moderatorBlockList.reverse() : []
|
||||||
);
|
);
|
||||||
|
|
||||||
export const selectPersonalTimeoutMap = createSelector(selectState, (state) => state.personalTimeoutMap);
|
export const selectPersonalTimeoutMap = (state: State) => selectState(state).personalTimeoutMap;
|
||||||
export const selectAdminTimeoutMap = createSelector(selectState, (state) => state.adminTimeoutMap);
|
export const selectAdminTimeoutMap = (state: State) => selectState(state).adminTimeoutMap;
|
||||||
export const selectModeratorTimeoutMap = createSelector(selectState, (state) => state.moderatorTimeoutMap);
|
export const selectModeratorTimeoutMap = (state: State) => selectState(state).moderatorTimeoutMap;
|
||||||
|
export const selectModeratorBlockListDelegatorsMap = (state: State) =>
|
||||||
export const selectModeratorBlockListDelegatorsMap = createSelector(
|
selectState(state).moderatorBlockListDelegatorsMap;
|
||||||
selectState,
|
export const selectTogglingForDelegatorMap = (state: State) => selectState(state).togglingForDelegatorMap;
|
||||||
(state) => state.moderatorBlockListDelegatorsMap
|
export const selectBlockingByUri = (state: State) => selectState(state).blockingByUri;
|
||||||
);
|
export const selectUnBlockingByUri = (state: State) => selectState(state).unBlockingByUri;
|
||||||
|
export const selectFetchingModerationBlockList = (state: State) => selectState(state).fetchingModerationBlockList;
|
||||||
export const selectTogglingForDelegatorMap = createSelector(selectState, (state) => state.togglingForDelegatorMap);
|
export const selectModerationDelegatesById = (state: State) => selectState(state).moderationDelegatesById;
|
||||||
|
export const selectIsFetchingModerationDelegates = (state: State) => selectState(state).fetchingModerationDelegates;
|
||||||
export const selectBlockingByUri = createSelector(selectState, (state) => state.blockingByUri);
|
export const selectModerationDelegatorsById = (state: State) => selectState(state).moderationDelegatorsById;
|
||||||
export const selectUnBlockingByUri = createSelector(selectState, (state) => state.unBlockingByUri);
|
export const selectIsFetchingModerationDelegators = (state: State) => selectState(state).fetchingModerationDelegators;
|
||||||
export const selectFetchingModerationBlockList = createSelector(
|
|
||||||
selectState,
|
|
||||||
(state) => state.fetchingModerationBlockList
|
|
||||||
);
|
|
||||||
|
|
||||||
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) => {
|
export const selectHasAdminChannel = createSelector(selectState, (state) => {
|
||||||
const myChannelIds = Object.keys(state.moderationDelegatorsById);
|
const myChannelIds = Object.keys(state.moderationDelegatorsById);
|
||||||
|
@ -107,7 +106,8 @@ export const selectCommentsByClaimId = createSelector(selectState, selectComment
|
||||||
return comments;
|
return comments;
|
||||||
});
|
});
|
||||||
|
|
||||||
export const selectSuperchatsByUri = createSelector(selectState, (state) => state.superChatsByUri);
|
// no superchats?
|
||||||
|
export const selectSuperchatsByUri = (state: State) => selectState(state).superChatsByUri;
|
||||||
|
|
||||||
export const selectTopLevelCommentsByClaimId = createSelector(selectState, selectCommentsById, (state, byId) => {
|
export const selectTopLevelCommentsByClaimId = createSelector(selectState, selectCommentsById, (state, byId) => {
|
||||||
const byClaimId = state.topLevelCommentsById || {};
|
const byClaimId = state.topLevelCommentsById || {};
|
||||||
|
@ -166,7 +166,7 @@ export const selectCommentsByUri = createSelector(selectState, (state) => {
|
||||||
return comments;
|
return comments;
|
||||||
});
|
});
|
||||||
|
|
||||||
export const selectLinkedCommentAncestors = createSelector(selectState, (state) => state.linkedCommentAncestors);
|
export const selectLinkedCommentAncestors = (state: State) => selectState(state).linkedCommentAncestors;
|
||||||
|
|
||||||
export const makeSelectCommentIdsForUri = (uri: string) =>
|
export const makeSelectCommentIdsForUri = (uri: string) =>
|
||||||
createSelector(selectState, selectCommentsByUri, selectClaimsById, (state, byUri) => {
|
createSelector(selectState, selectCommentsByUri, selectClaimsById, (state, byUri) => {
|
||||||
|
@ -174,38 +174,10 @@ export const makeSelectCommentIdsForUri = (uri: string) =>
|
||||||
return state.byId[claimId];
|
return state.byId[claimId];
|
||||||
});
|
});
|
||||||
|
|
||||||
export const selectMyReactionsByCommentId = createSelector(selectState, (state) => state.myReactsByCommentId);
|
export const selectPendingCommentReacts = (state: State) => selectState(state).pendingCommentReactions;
|
||||||
|
export const selectSettingsByChannelId = (state: State) => selectState(state).settingsByChannelId;
|
||||||
/**
|
export const selectFetchingCreatorSettings = (state: State) => selectState(state).fetchingSettings;
|
||||||
* makeSelectMyReactionsForComment
|
export const selectFetchingBlockedWords = (state: State) => selectState(state).fetchingBlockedWords;
|
||||||
*
|
|
||||||
* @param commentIdChannelId Format = "commentId:MyChannelId".
|
|
||||||
*/
|
|
||||||
export const makeSelectMyReactionsForComment = (commentIdChannelId: string) =>
|
|
||||||
createSelector(selectState, (state) => {
|
|
||||||
if (!state.myReactsByCommentId) {
|
|
||||||
return [];
|
|
||||||
}
|
|
||||||
|
|
||||||
return state.myReactsByCommentId[commentIdChannelId] || [];
|
|
||||||
});
|
|
||||||
|
|
||||||
export const makeSelectOthersReactionsForComment = (commentId: string) =>
|
|
||||||
createSelector(selectState, (state) => {
|
|
||||||
if (!state.othersReactsByCommentId) {
|
|
||||||
return {};
|
|
||||||
}
|
|
||||||
|
|
||||||
return state.othersReactsByCommentId[commentId] || {};
|
|
||||||
});
|
|
||||||
|
|
||||||
export const selectPendingCommentReacts = createSelector(selectState, (state) => state.pendingCommentReactions);
|
|
||||||
|
|
||||||
export const selectSettingsByChannelId = createSelector(selectState, (state) => state.settingsByChannelId);
|
|
||||||
|
|
||||||
export const selectFetchingCreatorSettings = createSelector(selectState, (state) => state.fetchingSettings);
|
|
||||||
|
|
||||||
export const selectFetchingBlockedWords = createSelector(selectState, (state) => state.fetchingBlockedWords);
|
|
||||||
|
|
||||||
export const makeSelectCommentsForUri = (uri: string) =>
|
export const makeSelectCommentsForUri = (uri: string) =>
|
||||||
createSelector(
|
createSelector(
|
||||||
|
|
Loading…
Reference in a new issue