Skip to content

Commit

Permalink
[INJIMOB-1168] - handle qr generation error of large VC (#1382)
Browse files Browse the repository at this point in the history
Signed-off-by: Sreenadh S <32409698+sree96@users.noreply.github.com>
  • Loading branch information
sree96 authored Apr 17, 2024
1 parent dd81074 commit 636a8a9
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion components/QrCodeOverlay.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import {VCMetadata} from '../shared/VCMetadata';
export const QrCodeOverlay: React.FC<QrCodeOverlayProps> = props => {
const {t} = useTranslation('VcDetails');
const [qrString, setQrString] = useState('');
const [qrError,setQrError] = useState(false);

async function getQRData(): Promise<string> {
let qrData: string;
Expand All @@ -35,6 +36,11 @@ export const QrCodeOverlay: React.FC<QrCodeOverlayProps> = props => {
return qrData;
}

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

useEffect(() => {
(async () => {
const qrString = await getQRData();
Expand All @@ -44,7 +50,7 @@ export const QrCodeOverlay: React.FC<QrCodeOverlayProps> = props => {
const [isQrOverlayVisible, setIsQrOverlayVisible] = useState(false);
const toggleQrOverlay = () => setIsQrOverlayVisible(!isQrOverlayVisible);
return (
qrString != '' && (
qrString != '' && !qrError && (
<React.Fragment>
<View testID="qrCodeView" style={Theme.QrCodeStyles.QrView}>
<Pressable
Expand All @@ -57,6 +63,7 @@ export const QrCodeOverlay: React.FC<QrCodeOverlayProps> = props => {
value={qrString}
backgroundColor={Theme.Colors.QRCodeBackgroundColor}
ecl={DEFAULT_ECL}
onError={onQRError}
/>
<View
testID="magnifierZoom"
Expand Down Expand Up @@ -94,6 +101,7 @@ export const QrCodeOverlay: React.FC<QrCodeOverlayProps> = props => {
value={qrString}
backgroundColor={Theme.Colors.QRCodeBackgroundColor}
ecl={DEFAULT_ECL}
onError={onQRError}
/>
</Centered>
</Column>
Expand Down

0 comments on commit 636a8a9

Please sign in to comment.