From 3b04e24a6bbe17cd677c6a7ea48df10da52b783d Mon Sep 17 00:00:00 2001 From: Marvin Sextro Date: Wed, 29 Dec 2021 00:53:31 +0100 Subject: [PATCH 1/3] Improve QR code viewer --- pages/pass.tsx | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/pages/pass.tsx b/pages/pass.tsx index 420ad6e..863a154 100644 --- a/pages/pass.tsx +++ b/pages/pass.tsx @@ -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(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 (
From 4f30b9b326432c531a18d4ca39a5e98709b41606 Mon Sep 17 00:00:00 2001 From: Marvin Sextro Date: Wed, 29 Dec 2021 00:57:06 +0100 Subject: [PATCH 2/3] Fix greek translation --- public/locales/el/index.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/public/locales/el/index.yml b/public/locales/el/index.yml index 6acfc98..831b2ac 100644 --- a/public/locales/el/index.yml +++ b/public/locales/el/index.yml @@ -25,4 +25,4 @@ privacyPolicy: Πολιτική Απορρήτου createdOnDevice: Δημιουργείται στη συσκευή σας openSourceTransparent: Ανοιχτού κώδικα και διαφανής hostedInEU: Φιλοξενείται στην ΕΕ -share: Συστήσει \ No newline at end of file +share: Κοινοποιήστε το \ No newline at end of file From 931b0806f96e3d92a89616bc3d6d488c02c42a1d Mon Sep 17 00:00:00 2001 From: Marvin Sextro Date: Wed, 29 Dec 2021 01:11:13 +0100 Subject: [PATCH 3/3] Scroll down after successful pass creation --- components/Form.tsx | 3 +++ 1 file changed, 3 insertions(+) diff --git a/components/Form.tsx b/components/Form.tsx index b0bfc65..7cb9937 100644 --- a/components/Form.tsx +++ b/components/Form.tsx @@ -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);