Fix comment channel not checked in Livestreams

## Change
Moved the fetch from `CommentList` to `CommentCreate` instead, which is used by both Content and Livestreams comments.
This commit is contained in:
infinite-persistence 2022-05-06 16:06:15 +08:00 committed by Thomas Zarebczan
parent 26f9cf3a4f
commit 208b701998
4 changed files with 25 additions and 27 deletions

View file

@ -5,14 +5,20 @@ import {
selectHasChannels, selectHasChannels,
selectFetchingMyChannels, selectFetchingMyChannels,
makeSelectTagInClaimOrChannelForUri, makeSelectTagInClaimOrChannelForUri,
selectMyChannelClaimIds,
} from 'redux/selectors/claims'; } from 'redux/selectors/claims';
import { CommentCreate } from './view'; import { CommentCreate } from './view';
import { DISABLE_SUPPORT_TAG } from 'constants/tags'; import { DISABLE_SUPPORT_TAG } from 'constants/tags';
import { doCommentCreate, doFetchCreatorSettings, doCommentById } from 'redux/actions/comments'; import {
doCommentCreate,
doFetchCreatorSettings,
doCommentById,
doFetchMyCommentedChannels,
} from 'redux/actions/comments';
import { doSendTip, doSendCashTip } from 'redux/actions/wallet'; import { doSendTip, doSendCashTip } from 'redux/actions/wallet';
import { doToast } from 'redux/actions/notifications'; import { doToast } from 'redux/actions/notifications';
import { selectActiveChannelClaim } from 'redux/selectors/app'; import { selectActiveChannelClaim } from 'redux/selectors/app';
import { selectSettingsByChannelId } from 'redux/selectors/comments'; import { selectMyCommentedChannelIdsForId, selectSettingsByChannelId } from 'redux/selectors/comments';
import { getChannelIdFromClaim } from 'util/claim'; import { getChannelIdFromClaim } from 'util/claim';
import { doOpenModal } from 'redux/actions/app'; import { doOpenModal } from 'redux/actions/app';
import { selectClientSetting } from 'redux/selectors/settings'; import { selectClientSetting } from 'redux/selectors/settings';
@ -45,12 +51,15 @@ const select = (state, props) => {
settingsByChannelId: selectSettingsByChannelId(state), settingsByChannelId: selectSettingsByChannelId(state),
supportDisabled: makeSelectTagInClaimOrChannelForUri(uri, DISABLE_SUPPORT_TAG)(state), supportDisabled: makeSelectTagInClaimOrChannelForUri(uri, DISABLE_SUPPORT_TAG)(state),
preferredCurrency: selectClientSetting(state, SETTINGS.PREFERRED_CURRENCY), preferredCurrency: selectClientSetting(state, SETTINGS.PREFERRED_CURRENCY),
myChannelClaimIds: selectMyChannelClaimIds(state),
myCommentedChannelIds: selectMyCommentedChannelIdsForId(state, claim?.claim_id),
}; };
}; };
const perform = { const perform = {
doCommentCreate, doCommentCreate,
doFetchCreatorSettings, doFetchCreatorSettings,
doFetchMyCommentedChannels,
doToast, doToast,
doCommentById, doCommentById,
doSendCashTip, doSendCashTip,

View file

@ -75,6 +75,9 @@ type Props = {
doSendTip: (params: {}, isSupport: boolean, successCb: (any) => void, errorCb: (any) => void, boolean) => void, doSendTip: (params: {}, isSupport: boolean, successCb: (any) => void, errorCb: (any) => void, boolean) => void,
doOpenModal: (id: string, any) => void, doOpenModal: (id: string, any) => void,
preferredCurrency: string, preferredCurrency: string,
myChannelClaimIds: ?Array<string>,
myCommentedChannelIds: ?Array<string>,
doFetchMyCommentedChannels: (claimId: ?string) => void,
}; };
export function CommentCreate(props: Props) { export function CommentCreate(props: Props) {
@ -111,6 +114,9 @@ export function CommentCreate(props: Props) {
setQuickReply, setQuickReply,
doOpenModal, doOpenModal,
preferredCurrency, preferredCurrency,
myChannelClaimIds,
myCommentedChannelIds,
doFetchMyCommentedChannels,
} = props; } = props;
const isMobile = useIsMobile(); const isMobile = useIsMobile();
@ -486,6 +492,13 @@ export function CommentCreate(props: Props) {
}; };
}, [isLivestream]); }, [isLivestream]);
// Determine my channels that have commented
React.useEffect(() => {
if (myCommentedChannelIds === undefined && claimId && myChannelClaimIds) {
doFetchMyCommentedChannels(claimId);
}
}, [claimId, myCommentedChannelIds, myChannelClaimIds]);
// ************************************************************************** // **************************************************************************
// Render // Render
// ************************************************************************** // **************************************************************************

View file

@ -4,7 +4,6 @@ import {
selectClaimIsMine, selectClaimIsMine,
selectFetchingMyChannels, selectFetchingMyChannels,
selectClaimsByUri, selectClaimsByUri,
selectMyChannelClaimIds,
} from 'redux/selectors/claims'; } from 'redux/selectors/claims';
import { import {
selectTopLevelCommentsForUri, selectTopLevelCommentsForUri,
@ -18,15 +17,8 @@ import {
selectCommentIdsForUri, selectCommentIdsForUri,
selectSettingsByChannelId, selectSettingsByChannelId,
selectPinnedCommentsForUri, selectPinnedCommentsForUri,
selectMyCommentedChannelIdsForId,
} from 'redux/selectors/comments'; } from 'redux/selectors/comments';
import { import { doCommentReset, doCommentList, doCommentById, doCommentReactList } from 'redux/actions/comments';
doCommentReset,
doCommentList,
doCommentById,
doCommentReactList,
doFetchMyCommentedChannels,
} from 'redux/actions/comments';
import { selectActiveChannelClaim } from 'redux/selectors/app'; import { selectActiveChannelClaim } from 'redux/selectors/app';
import { getChannelIdFromClaim } from 'util/claim'; import { getChannelIdFromClaim } from 'util/claim';
import { doFetchUserMemberships } from 'redux/actions/user'; import { doFetchUserMemberships } from 'redux/actions/user';
@ -56,8 +48,6 @@ const select = (state, props) => {
othersReactsById: selectOthersReacts(state), othersReactsById: selectOthersReacts(state),
activeChannelId: activeChannelClaim && activeChannelClaim.claim_id, activeChannelId: activeChannelClaim && activeChannelClaim.claim_id,
claimsByUri: selectClaimsByUri(state), claimsByUri: selectClaimsByUri(state),
myChannelClaimIds: selectMyChannelClaimIds(state),
myCommentedChannelIds: selectMyCommentedChannelIdsForId(state, claim?.claim_id),
}; };
}; };
@ -67,7 +57,6 @@ const perform = {
fetchReacts: doCommentReactList, fetchReacts: doCommentReactList,
resetComments: doCommentReset, resetComments: doCommentReset,
doFetchUserMemberships, doFetchUserMemberships,
doFetchMyCommentedChannels,
}; };
export default connect(select, perform)(CommentsList); export default connect(select, perform)(CommentsList);

View file

@ -52,10 +52,7 @@ type Props = {
fetchReacts: (commentIds: Array<string>) => Promise<any>, fetchReacts: (commentIds: Array<string>) => Promise<any>,
resetComments: (claimId: string) => void, resetComments: (claimId: string) => void,
claimsByUri: { [string]: any }, claimsByUri: { [string]: any },
myChannelClaimIds: ?Array<string>,
myCommentedChannelIds: ?Array<string>,
doFetchUserMemberships: (claimIdCsv: string) => void, doFetchUserMemberships: (claimIdCsv: string) => void,
doFetchMyCommentedChannels: (claimId: ?string) => void,
}; };
export default function CommentList(props: Props) { export default function CommentList(props: Props) {
@ -83,10 +80,7 @@ export default function CommentList(props: Props) {
fetchReacts, fetchReacts,
resetComments, resetComments,
claimsByUri, claimsByUri,
myChannelClaimIds,
myCommentedChannelIds,
doFetchUserMemberships, doFetchUserMemberships,
doFetchMyCommentedChannels,
} = props; } = props;
const isMobile = useIsMobile(); const isMobile = useIsMobile();
@ -268,13 +262,6 @@ export default function CommentList(props: Props) {
topLevelTotalPages, topLevelTotalPages,
]); ]);
// Determine my channels that have commented
useEffect(() => {
if (myCommentedChannelIds === undefined && claimId && myChannelClaimIds) {
doFetchMyCommentedChannels(claimId);
}
}, [claimId, myCommentedChannelIds, myChannelClaimIds]);
const commentProps = { isTopLevel: true, threadDepth: 3, uri, claimIsMine, linkedCommentId }; const commentProps = { isTopLevel: true, threadDepth: 3, uri, claimIsMine, linkedCommentId };
const actionButtonsProps = { const actionButtonsProps = {
totalComments, totalComments,