Skip to content

Commit

Permalink
remove hidden proposals from prop modal
Browse files Browse the repository at this point in the history
  • Loading branch information
cryptoseneca committed Mar 25, 2024
1 parent f264dfb commit 80fdbb8
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 24 deletions.
34 changes: 12 additions & 22 deletions packages/prop-house-webapp/src/components/RoundContent/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import { House, Proposal, Round, RoundType, Timed } from '@prophouse/sdk-react';
import TimedRoundProposalCard from '../TimedRoundProposalCard';
import TimedRoundModules from '../TimedRoundModules';
import InfRoundModules from '../InfRoundModules';
import { useHiddenPropIds } from '../../hooks/useHiddenPropIds';
import { useContentModeration } from '../../hooks/useContentModeration';

const RoundContent: React.FC<{
Expand All @@ -18,7 +17,7 @@ const RoundContent: React.FC<{
const { round, proposals, house } = props;

const [showVoteConfirmationModal, setShowVoteConfirmationModal] = useState(false);
const { hiddenPropIds, refresh } = useHiddenPropIds(round.address);

// eslint-disable-next-line
const { isMod, hideProp, hideRound } = useContentModeration(house);

Expand Down Expand Up @@ -46,26 +45,17 @@ const RoundContent: React.FC<{
<ErrorMessageCard message={'Submitted proposals will show up here'} />
) : (
<>
{hiddenPropIds === undefined ? (
<></>
) : (
proposals &&
proposals
.filter(p => !hiddenPropIds.includes(p.id))
.map((prop, index) => (
<Col key={index}>
<TimedRoundProposalCard
proposal={prop}
round={round}
mod={isMod}
hideProp={async (propId: number) => {
await hideProp(round.address, propId);
setTimeout(() => refresh(), 1000);
}}
/>
</Col>
))
)}
{proposals &&
proposals.map((prop, index) => (
<Col key={index}>
<TimedRoundProposalCard
proposal={prop}
round={round}
mod={isMod}
hideProp={async (propId: number) => await hideProp(round.address, propId)}
/>
</Col>
))}
</>
)}
</Col>
Expand Down
16 changes: 14 additions & 2 deletions packages/prop-house-webapp/src/pages/Round/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import RoundContent from '../../components/RoundContent';
import { setVoteAllotments } from '../../state/slices/voting';
import { removeHtmlFromString } from '../../utils/removeHtmlFromString';
import { RoundOrHouseContentLoadingCard } from '../../components/LoadingCards';
import { useHiddenPropIds } from '../../hooks/useHiddenPropIds';

const Round: React.FC<{}> = () => {
const propHouse = usePropHouse();
Expand All @@ -26,6 +27,9 @@ const Round: React.FC<{}> = () => {
const [loadedProposals, setLoadedProposals] = useState(false);
const [loadingProposalsFailed, setLoadingProposalsFailed] = useState(false);

// eslint-disable-next-line
const { hiddenPropIds, refresh } = useHiddenPropIds(round!.address);

// fetch proposals
useEffect(() => {
if (proposals || loadedProposals || !round) return;
Expand Down Expand Up @@ -54,7 +58,9 @@ const Round: React.FC<{}> = () => {

return (
<>
{isModalActive && proposals && <ProposalModal proposals={proposals} />}
{isModalActive && hiddenPropIds !== undefined && proposals && (
<ProposalModal proposals={proposals.filter(p => !hiddenPropIds.includes(p.id))} />
)}
{round && (
<OpenGraphElements
title={round.title}
Expand All @@ -75,7 +81,13 @@ const Round: React.FC<{}> = () => {
<NotFound />
) : (
<div className={classes.propCards}>
{proposals && <RoundContent round={round} house={house} proposals={proposals} />}
{hiddenPropIds !== undefined && proposals && (
<RoundContent
round={round}
house={house}
proposals={proposals.filter(p => !hiddenPropIds.includes(p.id))}
/>
)}
</div>
)}
</Container>
Expand Down

0 comments on commit 80fdbb8

Please sign in to comment.