Skip to content

Commit

Permalink
fix: Remove repetitive vc in discover
Browse files Browse the repository at this point in the history
  • Loading branch information
bibash28 committed Nov 1, 2024
1 parent 1dbc831 commit 859c137
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 8 deletions.
33 changes: 26 additions & 7 deletions lib/credentials/cubit/credentials_cubit.dart
Original file line number Diff line number Diff line change
Expand Up @@ -696,10 +696,12 @@ class CredentialsCubit extends Cubit<CredentialsState> {
for (final CredentialCategory category in getCredentialCategorySorted) {
final allCategoryVC = <CredInfo>[];

// /// tezVoucher is available only on Android platform
// if (isIOS) {
// allCategoryVC.remove(CredentialSubjectType.tezVoucher);
// }
/// tezVoucher is available only on Android platform
if (isIOS) {
allCategoryVC.removeWhere(
(item) => item.credentialType == CredentialSubjectType.tezVoucher,
);
}

// remove cards in discover based on profile
if (discoverCardsOptions != null) {
Expand All @@ -717,6 +719,7 @@ class CredentialsCubit extends Cubit<CredentialsState> {
case CredentialCategory.identityCards:

/// over 13
if (ldpVcType && discoverCardsOptions.displayOver13) {
allCategoryVC.add(
CredInfo(
Expand All @@ -727,6 +730,7 @@ class CredentialsCubit extends Cubit<CredentialsState> {
}

/// Over 15
if (ldpVcType && discoverCardsOptions.displayOver15) {
allCategoryVC.add(
CredInfo(
Expand Down Expand Up @@ -890,6 +894,7 @@ class CredentialsCubit extends Cubit<CredentialsState> {
case CredentialCategory.contactInfoCredentials:

/// Email Pass
if (ldpVcType && discoverCardsOptions.displayEmailPass) {
allCategoryVC.add(
CredInfo(
Expand Down Expand Up @@ -1041,6 +1046,11 @@ class CredentialsCubit extends Cubit<CredentialsState> {
credInfo.credentialType.supportSingleOnly) {
/// credential available case
for (final credential in credentialsOfSameType) {
final alreadyAdded = requiredCreds.any(
(item) =>
item.credentialType == credInfo.credentialType &&
item.formatType == credInfo.formatType,
);
if (isBlockchainAccount && supportAssociatedCredential) {
/// there can be multiple blockchain profiles
///
Expand All @@ -1052,7 +1062,7 @@ class CredentialsCubit extends Cubit<CredentialsState> {
if (isCurrentBlockchainAccount) {
/// if already added do not add
if (!requiredCreds.contains(credInfo)) {
if (!alreadyAdded) {
requiredCreds.add(credInfo);
}
}
Expand All @@ -1063,7 +1073,9 @@ class CredentialsCubit extends Cubit<CredentialsState> {
/// do not add if format matched
/// there can be same credentials with different format
} else {
requiredCreds.add(credInfo);
if (!alreadyAdded) {
requiredCreds.add(credInfo);
}
}
}
}
Expand All @@ -1075,7 +1087,14 @@ class CredentialsCubit extends Cubit<CredentialsState> {
!isCurrentBlockchainAccount) {
/// do not add if current blockchain acccount does not match
} else {
requiredCreds.add(credInfo);
final alreadyAdded = requiredCreds.any(
(item) =>
item.credentialType == credInfo.credentialType &&
item.formatType == credInfo.formatType,
);
if (!alreadyAdded) {
requiredCreds.add(credInfo);
}
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion lib/dashboard/profile/models/profile.dart
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,7 @@ class ProfileModel extends Equatable {
displayChainborn: false,
displayTezotopia: false,
displayVerifiableId: false,
displayVerifiableIdJwt: true,
displayVerifiableIdJwt: false,
displayOver65: false,
displayEmailPass: false,
displayEmailPassJwt: false,
Expand Down

0 comments on commit 859c137

Please sign in to comment.