Skip to content

Commit

Permalink
Merge pull request #234 from aeecleclair/fix/get-groups-allowed-to-vote
Browse files Browse the repository at this point in the history
fix(campaign): get groups allowed to vote for non admin
  • Loading branch information
guillaumetavernier authored Feb 9, 2024
2 parents a3da44e + a239a40 commit 32fe198
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions lib/vote/providers/can_vote_provider.dart
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:myecl/user/providers/user_provider.dart';
import 'package:myecl/vote/providers/voting_group_list_provider.dart';
import 'package:myecl/vote/providers/voter_list_provider.dart';

final canVoteProvider = StateProvider<bool>((ref) {
final me = ref.watch(userProvider);
final votingGroupList = ref.watch(votingGroupListProvider);
final votingGroupList = ref.watch(voterListProvider);
final myGroupIds = me.groups.map((e) => e.id).toList();
return votingGroupList.any((e) => myGroupIds.contains(e.id));
return votingGroupList.maybeWhen(
data: (voters) => voters.any((e) => myGroupIds.contains(e.groupId)),
orElse: () => false);
});

0 comments on commit 32fe198

Please sign in to comment.