Skip to content

Commit

Permalink
fix: remove vote details call from proposal details page
Browse files Browse the repository at this point in the history
  • Loading branch information
amass01 authored Aug 11, 2021
1 parent 8f3f5c0 commit a3652f8
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 28 deletions.
19 changes: 0 additions & 19 deletions src/actions/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -1346,25 +1346,6 @@ export const onFetchProposalVoteResults = (token) =>
});
});

export const onFetchVotesDetails = (token) =>
withCsrf((dispatch, _, csrf) => {
dispatch(act.REQUEST_VOTES_DETAILS({ token }));
return api
.proposalVoteDetails(csrf, token)
.then((response) =>
dispatch(
act.RECEIVE_VOTES_DETAILS({
...response,
token
})
)
)
.catch((error) => {
dispatch(act.RECEIVE_VOTES_DETAILS(null, error));
throw error;
});
});

export const onAuthorizeVote = (userid, token, version) =>
withCsrf((dispatch, _, csrf) => {
dispatch(act.REQUEST_AUTHORIZE_VOTE({ token }));
Expand Down
13 changes: 4 additions & 9 deletions src/containers/Proposal/Detail/hooks.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ export function useProposal(token, threadParentID) {
const onFetchProposalsVoteSummary = useAction(
act.onFetchProposalsBatchVoteSummary
);
const onFetchVotesDetails = useAction(act.onFetchVotesDetails);
const proposalSelector = useMemo(
() => sel.makeGetProposalByToken(tokenShort),
[tokenShort]
Expand Down Expand Up @@ -89,9 +88,7 @@ export function useProposal(token, threadParentID) {
};

const isMissingDetails = !(proposal && getDetailsFile(proposal.files));
const isMissingVoteSummary = !(
voteSummaries[tokenShort] && voteSummaries[tokenShort].details
);
const isMissingVoteSummary = !voteSummaries[tokenShort];
const needsInitialFetch = token && isMissingDetails;

const [remainingTokens, setRemainingTokens] = useState(
Expand Down Expand Up @@ -136,7 +133,8 @@ export function useProposal(token, threadParentID) {
if (hasRemainingTokens) {
const [tokensBatch, next] =
getTokensForProposalsPagination(remainingTokens);
// only fetch summaries and count if the proposal is a RFP. If it is a submission, just grab the records info.
// Fetch summaries and count only if the proposal is a RFP.
// If it is a submission, just grab the records info.
onFetchProposalsBatch(tokensBatch, isRfp, undefined, !isSubmission)
.then(() => {
setRemainingTokens(next);
Expand All @@ -150,10 +148,7 @@ export function useProposal(token, threadParentID) {
proposal?.state === PROPOSAL_STATE_VETTED &&
!loadingVoteSummary
) {
Promise.all([
onFetchProposalsVoteSummary(unfetchedSummariesTokens),
onFetchVotesDetails(token)
])
onFetchProposalsVoteSummary(unfetchedSummariesTokens)
.then(() => send(VERIFY))
.catch((e) => send(REJECT, e));
return send(FETCH);
Expand Down

0 comments on commit a3652f8

Please sign in to comment.