Skip to content

Commit

Permalink
[DDW-796] Lazy validation
Browse files Browse the repository at this point in the history
  • Loading branch information
lucas-barros committed Dec 3, 2021
1 parent 37c5353 commit ad76db3
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions source/renderer/app/stores/VotingStore.js
Expand Up @@ -449,17 +449,17 @@ export default class VotingStore extends Store {

@action _checkFundPhase = (now: Date) => {
const phaseValidation = {
[FundPhases.SNAPSHOT]: now < VOTING_CAST_START_DATE,
[FundPhases.VOTING]:
now >= VOTING_CAST_START_DATE && now <= VOTING_CAST_END_DATE,
[FundPhases.TALLYING]:
now > VOTING_CAST_END_DATE && now < VOTING_RESULTS_DATE,
[FundPhases.RESULTS]: now >= VOTING_RESULTS_DATE,
[FundPhases.SNAPSHOT]: (date: Date) => date < VOTING_CAST_START_DATE,
[FundPhases.VOTING]: (date: Date) =>
now >= VOTING_CAST_START_DATE && date < VOTING_CAST_END_DATE,
[FundPhases.TALLYING]: (date: Date) =>
now >= VOTING_CAST_END_DATE && date < VOTING_RESULTS_DATE,
[FundPhases.RESULTS]: (date: Date) => date >= VOTING_RESULTS_DATE,
};
this.fundPhase =
Object.keys(FundPhases)
.map((phase) => FundPhases[phase])
.find((phase) => phaseValidation[phase]) || FundPhases.SNAPSHOT;
.map((key) => FundPhases[key])
.find((phase) => phaseValidation[phase](now)) || FundPhases.SNAPSHOT;
};

_generateVotingRegistrationKey = async () => {
Expand Down

0 comments on commit ad76db3

Please sign in to comment.