mirror of
https://github.com/mosip/inji-wallet.git
synced 2026-01-09 05:27:57 -05:00
[INJIMOB-3167] add null checks in card view and cache to fix vc render after download (#2048)
Signed-off-by: Abhishek Paul <paul.apaul.abhishek.ap@gmail.com>
This commit is contained in:
@@ -76,7 +76,9 @@ export const VCCardView: React.FC<VCItemProps> = ({
|
||||
vcMetadata.issuerHost,
|
||||
)
|
||||
.then(response => {
|
||||
if(response && response.matchingCredentialIssuerMetadata) {
|
||||
setWellknown(response.matchingCredentialIssuerMetadata);
|
||||
}
|
||||
setFields(response.fields);
|
||||
})
|
||||
.catch(error => {
|
||||
@@ -88,7 +90,7 @@ export const VCCardView: React.FC<VCItemProps> = ({
|
||||
}
|
||||
}, [verifiableCredentialData]);
|
||||
|
||||
if (!isVCLoaded(controller.credential, fields) || !wellknown || !vc) {
|
||||
if (!isVCLoaded(controller.credential) || !wellknown || !vc) {
|
||||
return <VCCardSkeleton />;
|
||||
}
|
||||
|
||||
|
||||
@@ -456,8 +456,7 @@ export const fieldItemIterator = (
|
||||
};
|
||||
|
||||
export const isVCLoaded = (
|
||||
verifiableCredential: Credential | null,
|
||||
fields: string[],
|
||||
verifiableCredential: Credential | null
|
||||
) => {
|
||||
return verifiableCredential != null;
|
||||
};
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import NetInfo from '@react-native-community/netinfo';
|
||||
import { NativeModules } from 'react-native';
|
||||
import {NativeModules} from 'react-native';
|
||||
import Cloud from '../../shared/CloudBackupAndRestoreUtils';
|
||||
import getAllConfigurations, { CACHED_API } from '../../shared/api';
|
||||
import getAllConfigurations, {CACHED_API} from '../../shared/api';
|
||||
import {
|
||||
fetchKeyPair,
|
||||
generateKeyPair,
|
||||
@@ -30,17 +30,21 @@ export const IssuersService = () => {
|
||||
},
|
||||
checkInternet: async () => await NetInfo.fetch(),
|
||||
downloadIssuerWellknown: async (context: any) => {
|
||||
const wellknownResponse = (await VciClient.getInstance().getIssuerMetadata(
|
||||
context.selectedIssuer.credential_issuer_host,
|
||||
)) as issuerType;
|
||||
const wellknownCacheObject = createCacheObject(wellknownResponse);
|
||||
await setItem(
|
||||
API_CACHED_STORAGE_KEYS.fetchIssuerWellknownConfig(
|
||||
const wellknownResponse =
|
||||
(await VciClient.getInstance().getIssuerMetadata(
|
||||
context.selectedIssuer.credential_issuer_host,
|
||||
),
|
||||
wellknownCacheObject,
|
||||
'',
|
||||
);
|
||||
)) as issuerType;
|
||||
if (wellknownResponse) {
|
||||
const wellknownCacheObject = createCacheObject(wellknownResponse);
|
||||
await setItem(
|
||||
API_CACHED_STORAGE_KEYS.fetchIssuerWellknownConfig(
|
||||
context.selectedIssuer.credential_issuer_host,
|
||||
),
|
||||
wellknownCacheObject,
|
||||
'',
|
||||
);
|
||||
}
|
||||
|
||||
return wellknownResponse;
|
||||
},
|
||||
getCredentialTypes: async (context: any) => {
|
||||
@@ -238,12 +242,14 @@ export const IssuersService = () => {
|
||||
const issuerMetadata = (await VciClient.getInstance().getIssuerMetadata(
|
||||
credentialIssuer,
|
||||
)) as issuerType;
|
||||
const wellknownCacheObject = createCacheObject(issuerMetadata);
|
||||
await setItem(
|
||||
API_CACHED_STORAGE_KEYS.fetchIssuerWellknownConfig(credentialIssuer),
|
||||
wellknownCacheObject,
|
||||
'',
|
||||
);
|
||||
if (issuerMetadata) {
|
||||
const wellknownCacheObject = createCacheObject(issuerMetadata);
|
||||
await setItem(
|
||||
API_CACHED_STORAGE_KEYS.fetchIssuerWellknownConfig(credentialIssuer),
|
||||
wellknownCacheObject,
|
||||
'',
|
||||
);
|
||||
}
|
||||
return issuerMetadata;
|
||||
},
|
||||
constructProof: async (context: any) => {
|
||||
|
||||
@@ -251,6 +251,9 @@ async function generateCacheAPIFunctionWithCachePreference(
|
||||
return cachedData.response;
|
||||
} else {
|
||||
const response = await fetchCall();
|
||||
if(!response) {
|
||||
throw new Error('Received Empty response in fetch call');
|
||||
}
|
||||
const cacheObject = createCacheObject(response);
|
||||
setItem(cacheKey, cacheObject, '').then(() =>
|
||||
console.info('Cached response for ' + cacheKey),
|
||||
|
||||
Reference in New Issue
Block a user