Skip to content

Commit f85680c

Browse files
committed
chore: code review changes
1 parent 090ba58 commit f85680c

File tree

5 files changed

+10
-22
lines changed

5 files changed

+10
-22
lines changed

catalyst_voices/packages/internal/catalyst_voices_blocs/lib/src/voting/voting_cubit.dart

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -224,10 +224,7 @@ final class VotingCubit extends Cubit<VotingState>
224224
}
225225

226226
VotingPhaseProgressViewModel? _buildVotingPhase(Campaign? campaign) {
227-
final campaignVotingPhase = campaign?.phaseStateTo(
228-
CampaignPhaseType.communityVoting,
229-
DateTimeExt.now(),
230-
);
227+
final campaignVotingPhase = campaign?.phaseStateTo(CampaignPhaseType.communityVoting);
231228
final campaignStartDate = campaign?.startDate;
232229

233230
if (campaignVotingPhase != null && campaignStartDate != null) {

catalyst_voices/packages/internal/catalyst_voices_blocs/lib/src/voting_ballot/voting_ballot_bloc.dart

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -153,10 +153,7 @@ final class VotingBallotBloc extends Bloc<VotingBallotEvent, VotingBallotState>
153153
}
154154

155155
VotingPhaseProgressViewModel? _buildVotingPhase(Campaign? campaign) {
156-
final campaignVotingPhase = campaign?.phaseStateTo(
157-
CampaignPhaseType.communityVoting,
158-
DateTimeExt.now(),
159-
);
156+
final campaignVotingPhase = campaign?.phaseStateTo(CampaignPhaseType.communityVoting);
160157
final campaignStartDate = campaign?.startDate;
161158

162159
if (campaignVotingPhase != null && campaignStartDate != null) {

catalyst_voices/packages/internal/catalyst_voices_models/lib/src/campaign/campaign.dart

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -100,10 +100,7 @@ Project Catalyst turns economic power into innovation power by using the Cardano
100100
}
101101

102102
bool get isVotingStateActive {
103-
return phaseStateTo(
104-
CampaignPhaseType.communityVoting,
105-
DateTimeExt.now(),
106-
).status.isActive;
103+
return phaseStateTo(CampaignPhaseType.communityVoting).status.isActive;
107104
}
108105

109106
@override
@@ -182,10 +179,13 @@ Project Catalyst turns economic power into innovation power by using the Cardano
182179
return categories.any((element) => element.id.id == id);
183180
}
184181

185-
/// Returns the state of the campaign for a specific phase at given [date].
182+
/// Returns the state of the campaign for a specific phase at given [date], which defaults to
183+
/// [DateTimeExt.now].
186184
/// It's a shortcut for [state] when you are only interested in a specific phase. And want to know
187185
/// the status of that phase.
188-
CampaignPhaseState phaseStateTo(CampaignPhaseType type, DateTime date) {
186+
CampaignPhaseState phaseStateTo(CampaignPhaseType type, [DateTime? date]) {
187+
date ??= DateTimeExt.now();
188+
189189
final phase = timeline.phases.firstWhere(
190190
(phase) => phase.type == type,
191191
orElse: () => throw StateError('Type $type not found'),

catalyst_voices/packages/internal/catalyst_voices_repositories/lib/src/campaign/campaign_repository.dart

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,7 @@ final class CampaignRepositoryImpl implements CampaignRepository {
3232

3333
@override
3434
Future<List<Campaign>> getAllCampaigns() async {
35-
return [
36-
Campaign.f15(),
37-
Campaign.f14(),
38-
];
35+
return Campaign.all;
3936
}
4037

4138
@override

catalyst_voices/packages/internal/catalyst_voices_services/lib/src/campaign/campaign_service.dart

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -199,10 +199,7 @@ final class CampaignServiceImpl implements CampaignService {
199199

200200
Future<Campaign> _updateSubmissionCloseDate(Campaign campaign) async {
201201
final proposalSubmissionTime = campaign
202-
.phaseStateTo(
203-
CampaignPhaseType.proposalSubmission,
204-
DateTimeExt.now(),
205-
)
202+
.phaseStateTo(CampaignPhaseType.proposalSubmission)
206203
.phase
207204
.timeline
208205
.to;

0 commit comments

Comments
 (0)