Commit a8529ef 1 parent 73b0efe commit a8529ef Copy full SHA for a8529ef
File tree 1 file changed +25
-1
lines changed
app/lib/page/profile/account
1 file changed +25
-1
lines changed Original file line number Diff line number Diff line change @@ -52,7 +52,21 @@ class _AccountManagePageState extends State<AccountManagePage> {
52
52
}
53
53
54
54
Future <void > _init () async {
55
- faucets = await webApi.encointer.getAllFaucetsWithAccount ();
55
+ final allFaucets = await webApi.encointer.getAllFaucetsWithAccount ();
56
+
57
+ // show faucets we have reputation for and faucets for `chosenCid`.
58
+ final relevantCids = _appStore.encointer.account! .reputations.values.map ((e) => e.communityIdentifier).toSet ()
59
+ ..add (_appStore.encointer.chosenCid! );
60
+
61
+ faucets = Map .fromEntries (allFaucets.entries.where ((e) {
62
+ final whitelist = e.value.whitelist;
63
+ if (whitelist == null ) {
64
+ // if the whitelist is null, all communities may access it.
65
+ return true ;
66
+ } else {
67
+ return containsAny (whitelist, relevantCids.toList ());
68
+ }
69
+ }));
56
70
setState (() {});
57
71
}
58
72
@@ -391,3 +405,13 @@ class CommunityIcon extends StatelessWidget {
391
405
);
392
406
}
393
407
}
408
+
409
+ /// Checks if any entry in list one is contained in another list.
410
+ bool containsAny (List <dynamic > list1, List <dynamic > list2) {
411
+ for (final entry in list1) {
412
+ if (list2.contains (entry)) {
413
+ return true ;
414
+ }
415
+ }
416
+ return false ;
417
+ }
You can’t perform that action at this time.
0 commit comments