|
1 | 1 | // Package imports:
|
2 | 2 | import 'package:built_collection/built_collection.dart';
|
| 3 | +import 'package:invoiceninja_flutter/constants.dart'; |
3 | 4 | import 'package:memoize/memoize.dart';
|
4 | 5 |
|
5 | 6 | // Project imports:
|
@@ -127,13 +128,36 @@ List<String?> sizeList(BuiltMap<String, SizeEntity> sizeMap) {
|
127 | 128 | return list;
|
128 | 129 | }
|
129 | 130 |
|
130 |
| -var memoizedGatewayList = memo1( |
131 |
| - (BuiltMap<String, GatewayEntity> gatewayMap) => gatewayList(gatewayMap)); |
132 |
| - |
133 |
| -List<String?> gatewayList(BuiltMap<String, GatewayEntity> gatewayMap) { |
134 |
| - final list = gatewayMap.keys |
135 |
| - .where((gatewayId) => gatewayMap[gatewayId]!.isVisible) |
136 |
| - .toList(); |
| 131 | +var memoizedGatewayList = memo2( |
| 132 | + (BuiltMap<String, GatewayEntity> gatewayMap, bool isHosted) => |
| 133 | + gatewayList(gatewayMap, isHosted)); |
| 134 | + |
| 135 | +List<String?> gatewayList( |
| 136 | + BuiltMap<String, GatewayEntity> gatewayMap, bool isHosted) { |
| 137 | + final list = gatewayMap.keys.where((gatewayId) { |
| 138 | + final gateway = gatewayMap[gatewayId]!; |
| 139 | + |
| 140 | + if (!gateway.isVisible) { |
| 141 | + return false; |
| 142 | + } |
| 143 | + |
| 144 | + if (isHosted) { |
| 145 | + if ([ |
| 146 | + kGatewayPayPalExpress, |
| 147 | + kGatewayPayPalREST, |
| 148 | + ].contains(gateway.id)) { |
| 149 | + return false; |
| 150 | + } |
| 151 | + } else { |
| 152 | + if ([ |
| 153 | + kGatewayPayPalPlatform, |
| 154 | + ].contains(gateway.id)) { |
| 155 | + return false; |
| 156 | + } |
| 157 | + } |
| 158 | + |
| 159 | + return true; |
| 160 | + }).toList(); |
137 | 161 |
|
138 | 162 | list.sort((idA, idB) =>
|
139 | 163 | gatewayMap[idA]!.sortOrder.compareTo(gatewayMap[idB]!.sortOrder));
|
|
0 commit comments