Skip to content

Commit

Permalink
generate QR always
Browse files Browse the repository at this point in the history
Signed-off-by: Sreenadh S <[email protected]>
  • Loading branch information
sree96 committed May 21, 2024
1 parent 7fd13ed commit cd5a1d3
Showing 1 changed file with 3 additions and 15 deletions.
18 changes: 3 additions & 15 deletions components/QrCodeOverlay.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import {SvgImage} from './ui/svg';
// @ts-ignore
import {generateQRData} from '@mosip/pixelpass';
import {VerifiableCredential} from '../machines/VerifiableCredential/VCMetaMachine/vc';
import RNSecureKeyStore, {ACCESSIBLE} from 'react-native-secure-key-store';
import {DEFAULT_ECL} from '../shared/constants';
import {VCMetadata} from '../shared/VCMetadata';

Expand All @@ -19,27 +18,16 @@ export const QrCodeOverlay: React.FC<QrCodeOverlayProps> = props => {
const [qrString, setQrString] = useState('');
const [qrError, setQrError] = useState(false);

async function getQRData(): Promise<string> {
let qrData: string;
try {
qrData = await RNSecureKeyStore.get(props.meta.id);
} catch {
qrData = generateQRData(JSON.stringify(props.verifiableCredential));
await RNSecureKeyStore.set(props.meta.id, qrData, {
accessible: ACCESSIBLE.ALWAYS_THIS_DEVICE_ONLY,
});
}
return qrData;
}

function onQRError() {
console.warn('Data is too big');
setQrError(true);
}

useEffect(() => {
(async () => {
const qrString = await getQRData();
const qrString = generateQRData(
JSON.stringify(props.verifiableCredential),
);
setQrString(qrString);
})();
}, [qrString]);
Expand Down

0 comments on commit cd5a1d3

Please sign in to comment.