Skip to content

Commit

Permalink
fix: list credential page
Browse files Browse the repository at this point in the history
Signed-off-by: Sai Ranjit Tummalapalli <[email protected]>
  • Loading branch information
sairanjit committed Apr 15, 2024
1 parent 189cefc commit 8ce304f
Show file tree
Hide file tree
Showing 8 changed files with 50 additions and 136 deletions.
16 changes: 16 additions & 0 deletions app/components/record/RecordField.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,22 @@ const RecordField: React.FC<RecordFieldProps> = ({
},
})

const isJSON = (text: string) => {
if (typeof text !== 'string') {
return false
}
try {
JSON.parse(text)
return true
} catch (error) {
return false
}
}

if (isJSON(field?.value)) {
return
}

return (
<View style={styles.container}>
<View style={styles.valueContainer}>
Expand Down
9 changes: 2 additions & 7 deletions app/screens/CredentialDetails.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,7 @@ import { CredentialMetadata, customMetadata } from '../types/metadata'
import { CredentialStackParams, Screens } from '../types/navigators'
import { ModalUsage } from '../types/remove'
import { useAppAgent } from '../utils/agent'
import {
credentialTextColor,
getCredentialIdentifiers,
isValidAnonCredsCredential,
toImageSource,
} from '../utils/credential'
import { credentialTextColor, getCredentialIdentifiers, toImageSource } from '../utils/credential'
import { formatTime, getCredentialConnectionLabel } from '../utils/helpers'
import { buildFieldsFromAnonCredsCredential } from '../utils/oca'
import { useSocialShare } from '../utils/social-share'
Expand Down Expand Up @@ -163,7 +158,7 @@ const CredentialDetails: React.FC<CredentialDetailsProps> = ({ navigation, route
}, [])

useEffect(() => {
if (!(credential && isValidAnonCredsCredential(credential))) {
if (!credential) {
return
}

Expand Down
9 changes: 2 additions & 7 deletions app/screens/CredentialOffer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,7 @@ import { TabStacks, NotificationStackParams, Screens } from '../types/navigators
import { W3CCredentialAttributeField } from '../types/record'
import { ModalUsage } from '../types/remove'
import { useAppAgent } from '../utils/agent'
import {
buildFieldsFromJSONLDCredential,
formatCredentialSubject,
getCredentialIdentifiers,
isValidAnonCredsCredential,
} from '../utils/credential'
import { buildFieldsFromJSONLDCredential, formatCredentialSubject, getCredentialIdentifiers } from '../utils/credential'
import { getCredentialConnectionLabel } from '../utils/helpers'
import { buildFieldsFromAnonCredsCredential } from '../utils/oca'
import { testIdWithKey } from '../utils/testable'
Expand Down Expand Up @@ -106,7 +101,7 @@ const CredentialOffer: React.FC<CredentialOfferProps> = ({ navigation, route })
}, [])

useEffect(() => {
if (!(credential && isValidAnonCredsCredential(credential))) {
if (!credential) {
return
}

Expand Down
4 changes: 2 additions & 2 deletions app/screens/ListCredentials.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ const ListCredentials: React.FC = () => {

const updatedCredentials = await Promise.all(
credentials.map(async credential => {
if (!isW3CCredential(credential)) {
if (isW3CCredential(credential)) {
const credentialRecordId = credential.credentials[0].credentialRecordId
try {
const record = await getW3cCredentialRecordById(agent, credentialRecordId)
Expand All @@ -78,7 +78,7 @@ const ListCredentials: React.FC = () => {
updateCredentials().then(updatedCredentials => {
setCredentialList(updatedCredentials)
})
}, [credentialList])
}, [])

return (
<View style={styles.container}>
Expand Down
11 changes: 8 additions & 3 deletions app/utils/credential.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@ import { luminanceForHexColor } from './luminance'
export const isValidAnonCredsCredential = (credential: CredentialExchangeRecord) => {
return (
credential &&
(credential.state === CredentialState.OfferReceived ||
credential.credentials.find(c => c.credentialRecordType !== 'anoncreds'))
credential.state === CredentialState.OfferReceived &&
credential.credentialAttributes &&
credential.credentialAttributes?.length > 0
)
}

Expand Down Expand Up @@ -37,7 +38,11 @@ export const getCredentialIdentifiers = (credential: CredentialExchangeRecord) =
}

export const isW3CCredential = (credential: CredentialExchangeRecord) => {
return credential && credential.credentials.find(c => c.credentialRecordType === 'w3c')
return (
credential &&
credential.credentials[0].credentialRecordType === 'w3c' &&
credential.credentialAttributes?.length === 0
)
}

export const sanitizeString = (str: string) => {
Expand Down
8 changes: 4 additions & 4 deletions ios/AdeyaWallet.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -507,7 +507,7 @@
ASSETCATALOG_COMPILER_INCLUDE_ALL_APPICON_ASSETS = NO;
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_ENTITLEMENTS = AdeyaWallet/AdeyaWallet.entitlements;
CURRENT_PROJECT_VERSION = 25;
CURRENT_PROJECT_VERSION = 27;
DEVELOPMENT_ASSET_PATHS = "";
DEVELOPMENT_TEAM = Z5W7KRPGHZ;
ENABLE_BITCODE = NO;
Expand All @@ -517,7 +517,7 @@
"$(inherited)",
"@executable_path/Frameworks",
);
MARKETING_VERSION = 1.0.6;
MARKETING_VERSION = 1.0.7;
OTHER_LDFLAGS = (
"$(inherited)",
"-ObjC",
Expand Down Expand Up @@ -545,7 +545,7 @@
CODE_SIGN_ENTITLEMENTS = AdeyaWallet/AdeyaWallet.entitlements;
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 25;
CURRENT_PROJECT_VERSION = 27;
DEVELOPMENT_ASSET_PATHS = "";
DEVELOPMENT_TEAM = Z5W7KRPGHZ;
INFOPLIST_FILE = AdeyaWallet/Info.plist;
Expand All @@ -554,7 +554,7 @@
"$(inherited)",
"@executable_path/Frameworks",
);
MARKETING_VERSION = 1.0.6;
MARKETING_VERSION = 1.0.7;
OTHER_LDFLAGS = (
"$(inherited)",
"-ObjC",
Expand Down
4 changes: 2 additions & 2 deletions ios/Podfile
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ setup_permissions([
# dependencies: {
# ...(process.env.NO_FLIPPER ? { 'react-native-flipper': { platforms: { ios: null } } } : {}),
# ```
flipper_config = ENV['NO_FLIPPER'] == "1" ? FlipperConfiguration.disabled : FlipperConfiguration.enabled
# flipper_config = ENV['NO_FLIPPER'] == "1" ? FlipperConfiguration.disabled : FlipperConfiguration.enabled

linkage = ENV['USE_FRAMEWORKS']
if linkage != nil
Expand All @@ -53,7 +53,7 @@ target 'AdeyaWallet' do
#
# Note that if you have use_frameworks! enabled, Flipper will not work and
# you should disable the next line.
:flipper_configuration => flipper_config,
# :flipper_configuration => flipper_config,
# An absolute path to your application root.
:app_path => "#{Pod::Config.instance.installation_root}/.."
)
Expand Down
Loading

0 comments on commit 8ce304f

Please sign in to comment.