Skip to content

Commit

Permalink
removed unnecessary fragment
Browse files Browse the repository at this point in the history
  • Loading branch information
Israellund committed Nov 14, 2024
1 parent 8ded076 commit db2edca
Showing 1 changed file with 120 additions and 122 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -298,131 +298,129 @@ const DiscussionsPage = ({ topicName }: DiscussionsPageProps) => {
/>

{selectedView === VIEWS[0].value ? (
<>
<Virtuoso
className="thread-list"
style={{ height: '100%', width: '100%' }}
data={isInitialLoading ? [] : filteredThreads}
customScrollParent={containerRef.current}
itemContent={(i, thread) => {
const discussionLink = getProposalUrlPath(
thread.slug,
`${thread.identifier}-${slugify(thread.title)}`,
);

const isTopicGated = !!(memberships || []).find(
(membership) =>
thread?.topic?.id &&
membership.topics.find((t) => t.id === thread.topic!.id),
);
const isActionAllowedInGatedTopic = !!(memberships || []).find(
(membership) =>
thread?.topic?.id &&
membership.topics.find((t) => t.id === thread.topic!.id) &&
membership.isAllowed,
);
const isRestrictedMembership =
!isAdmin && isTopicGated && !isActionAllowedInGatedTopic;
const foundTopicPermissions = topicPermissions.find(
(tp) => tp.id === thread.topic!.id,
);
const disabledActionsTooltipText = getThreadActionTooltipText({
<Virtuoso
className="thread-list"
style={{ height: '100%', width: '100%' }}
data={isInitialLoading ? [] : filteredThreads}
customScrollParent={containerRef.current}
itemContent={(i, thread) => {
const discussionLink = getProposalUrlPath(
thread.slug,
`${thread.identifier}-${slugify(thread.title)}`,
);

const isTopicGated = !!(memberships || []).find(
(membership) =>
thread?.topic?.id &&
membership.topics.find((t) => t.id === thread.topic!.id),
);
const isActionAllowedInGatedTopic = !!(memberships || []).find(
(membership) =>
thread?.topic?.id &&
membership.topics.find((t) => t.id === thread.topic!.id) &&
membership.isAllowed,
);
const isRestrictedMembership =
!isAdmin && isTopicGated && !isActionAllowedInGatedTopic;
const foundTopicPermissions = topicPermissions.find(
(tp) => tp.id === thread.topic!.id,
);
const disabledActionsTooltipText = getThreadActionTooltipText({
isCommunityMember: !!user.activeAccount,
isThreadArchived: !!thread?.archivedAt,
isThreadLocked: !!thread?.lockedAt,
isThreadTopicGated: isRestrictedMembership,
});
const disabledReactPermissionTooltipText =
getThreadActionTooltipText({
isCommunityMember: !!user.activeAccount,
isThreadArchived: !!thread?.archivedAt,
isThreadLocked: !!thread?.lockedAt,
isThreadTopicGated: isRestrictedMembership,
threadTopicInteractionRestrictions:
!isAdmin &&
!foundTopicPermissions?.permissions?.includes(
// this should be updated if we start displaying recent comments on this page
PermissionEnum.CREATE_THREAD_REACTION,
)
? foundTopicPermissions?.permissions
: undefined,
});
const disabledReactPermissionTooltipText =
getThreadActionTooltipText({
isCommunityMember: !!user.activeAccount,
threadTopicInteractionRestrictions:
!isAdmin &&
!foundTopicPermissions?.permissions?.includes(
// this should be updated if we start displaying recent comments on this page
PermissionEnum.CREATE_THREAD_REACTION,
)
? foundTopicPermissions?.permissions
: undefined,
});
const disabledCommentPermissionTooltipText =
getThreadActionTooltipText({
isCommunityMember: !!user.activeAccount,
threadTopicInteractionRestrictions:
!isAdmin &&
!foundTopicPermissions?.permissions?.includes(
PermissionEnum.CREATE_COMMENT,
)
? foundTopicPermissions?.permissions
: undefined,
});
const isThreadTopicInContest = checkIsTopicInContest(
contestsData.all,
thread?.topic?.id,
);

return (
<>
<ThreadCard
key={thread?.id + '-' + thread.readOnly}
thread={thread}
canReact={
disabledReactPermissionTooltipText
? !disabledReactPermissionTooltipText
: !disabledActionsTooltipText
}
canComment={
disabledCommentPermissionTooltipText
? !disabledCommentPermissionTooltipText
: !disabledActionsTooltipText
}
onEditStart={() =>
navigate(`${discussionLink}?isEdit=true`)
}
onStageTagClick={() => {
navigate(`/discussions?stage=${thread.stage}`);
}}
threadHref={`${getScopePrefix()}${discussionLink}`}
onBodyClick={() => {
const scrollEle =
document.getElementsByClassName('Body')[0];
localStorage[`${communityId}-discussions-scrollY`] =
scrollEle.scrollTop;
}}
onCommentBtnClick={() =>
navigate(`${discussionLink}?focusComments=true`)
}
disabledActionsTooltipText={
disabledCommentPermissionTooltipText ||
disabledReactPermissionTooltipText ||
disabledActionsTooltipText
}
hideRecentComments
editingDisabled={isThreadTopicInContest}
/>
<CWGrowlTemplate
headerText="Attention!"
bodyText="'Overview' page has been merged with the 'All' page"
buttonText="test"
growlType="discussion"
/>
</>
);
}}
endReached={() => {
hasNextPage && fetchNextPage();
}}
overscan={50}
components={{
// eslint-disable-next-line react/no-multi-comp
EmptyPlaceholder: () => (
<EmptyThreadsPlaceholder
isInitialLoading={isInitialLoading}
isOnArchivePage={isOnArchivePage}
const disabledCommentPermissionTooltipText =
getThreadActionTooltipText({
isCommunityMember: !!user.activeAccount,
threadTopicInteractionRestrictions:
!isAdmin &&
!foundTopicPermissions?.permissions?.includes(
PermissionEnum.CREATE_COMMENT,
)
? foundTopicPermissions?.permissions
: undefined,
});
const isThreadTopicInContest = checkIsTopicInContest(
contestsData.all,
thread?.topic?.id,
);

return (
<>
<ThreadCard
key={thread?.id + '-' + thread.readOnly}
thread={thread}
canReact={
disabledReactPermissionTooltipText
? !disabledReactPermissionTooltipText
: !disabledActionsTooltipText
}
canComment={
disabledCommentPermissionTooltipText
? !disabledCommentPermissionTooltipText
: !disabledActionsTooltipText
}
onEditStart={() =>
navigate(`${discussionLink}?isEdit=true`)
}
onStageTagClick={() => {
navigate(`/discussions?stage=${thread.stage}`);
}}
threadHref={`${getScopePrefix()}${discussionLink}`}
onBodyClick={() => {
const scrollEle =
document.getElementsByClassName('Body')[0];
localStorage[`${communityId}-discussions-scrollY`] =
scrollEle.scrollTop;
}}
onCommentBtnClick={() =>
navigate(`${discussionLink}?focusComments=true`)
}
disabledActionsTooltipText={
disabledCommentPermissionTooltipText ||
disabledReactPermissionTooltipText ||
disabledActionsTooltipText
}
hideRecentComments
editingDisabled={isThreadTopicInContest}
/>
),
}}
/>
</>
<CWGrowlTemplate
headerText="Attention!"
bodyText="'Overview' page has been merged with the 'All' page"
buttonText="test"
growlType="discussion"
/>
</>
);
}}
endReached={() => {
hasNextPage && fetchNextPage();
}}
overscan={50}
components={{
// eslint-disable-next-line react/no-multi-comp
EmptyPlaceholder: () => (
<EmptyThreadsPlaceholder
isInitialLoading={isInitialLoading}
isOnArchivePage={isOnArchivePage}
/>
),
}}
/>
) : (
<OverviewPage />
)}
Expand Down

0 comments on commit db2edca

Please sign in to comment.