Skip to content

Commit

Permalink
Merge pull request #144 from covidpass-org/dev
Browse files Browse the repository at this point in the history
Improve QR code viewer
  • Loading branch information
marvinsxtr authored Dec 29, 2021
2 parents 40397d2 + 931b080 commit e765408
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 2 deletions.
3 changes: 3 additions & 0 deletions components/Form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,9 @@ function Form(): JSX.Element {
const passBlob = new Blob([pass], {type: "application/vnd.apple.pkpass"});
saveAs(passBlob, 'covid.pkpass');
setLoading(false);

var scrollingElement = (document.scrollingElement || document.body);
scrollingElement.scrollTop = scrollingElement.scrollHeight;
} catch (e) {
setErrorMessage(e.message);
setLoading(false);
Expand Down
22 changes: 21 additions & 1 deletion pages/pass.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,37 @@ import {serverSideTranslations} from 'next-i18next/serverSideTranslations';

import React, {useEffect, useState} from "react";
import QRCode from "react-qr-code";

import Card from '../components/Card';
import Logo from "../components/Logo";

function Pass(): JSX.Element {
const [fragment, setFragment] = useState<string>(undefined);

function closeViewer() {
setFragment(undefined);
window.location.href = '/';
}

useEffect(() => {
const rawFragment = window.location.hash.substring(1);
const decodedFragment = Buffer.from(rawFragment, 'base64').toString();
setFragment(decodedFragment);
}, [fragment]);

window.location.replace('#');
if (typeof window.history.replaceState == 'function') {
const href = window.location.href;
history.replaceState({}, '', href.slice(0, href.lastIndexOf('/')));
}

document.addEventListener('visibilitychange', () => {
if (document.hidden) {
closeViewer();
}
});

window.addEventListener('blur', closeViewer);
}, []);

return (
<div className="py-6 flex flex-col space-y-5 items-center">
Expand Down
2 changes: 1 addition & 1 deletion public/locales/el/index.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,4 @@ privacyPolicy: Πολιτική Απορρήτου
createdOnDevice: Δημιουργείται στη συσκευή σας
openSourceTransparent: Ανοιχτού κώδικα και διαφανής
hostedInEU: Φιλοξενείται στην ΕΕ
share: Συστήσει
share: Κοινοποιήστε το

0 comments on commit e765408

Please sign in to comment.