Skip to content

Commit 81192f5

Browse files
author
Lucas Araujo
committed
[DDW-796] Lazy validation
1 parent dc9e1c7 commit 81192f5

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

source/renderer/app/stores/VotingStore.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -449,17 +449,17 @@ export default class VotingStore extends Store {
449449

450450
@action _checkFundPhase = (now: Date) => {
451451
const phaseValidation = {
452-
[FundPhases.SNAPSHOT]: now < VOTING_CAST_START_DATE,
453-
[FundPhases.VOTING]:
454-
now >= VOTING_CAST_START_DATE && now <= VOTING_CAST_END_DATE,
455-
[FundPhases.TALLYING]:
456-
now > VOTING_CAST_END_DATE && now < VOTING_RESULTS_DATE,
457-
[FundPhases.RESULTS]: now >= VOTING_RESULTS_DATE,
452+
[FundPhases.SNAPSHOT]: (date: Date) => date < VOTING_CAST_START_DATE,
453+
[FundPhases.VOTING]: (date: Date) =>
454+
now >= VOTING_CAST_START_DATE && date < VOTING_CAST_END_DATE,
455+
[FundPhases.TALLYING]: (date: Date) =>
456+
now >= VOTING_CAST_END_DATE && date < VOTING_RESULTS_DATE,
457+
[FundPhases.RESULTS]: (date: Date) => date >= VOTING_RESULTS_DATE,
458458
};
459459
this.fundPhase =
460460
Object.keys(FundPhases)
461-
.map((phase) => FundPhases[phase])
462-
.find((phase) => phaseValidation[phase]) || FundPhases.SNAPSHOT;
461+
.map((key) => FundPhases[key])
462+
.find((phase) => phaseValidation[phase](now)) || FundPhases.SNAPSHOT;
463463
};
464464

465465
_generateVotingRegistrationKey = async () => {

0 commit comments

Comments
 (0)