Try to fix QR code viewer

This commit is contained in:
Marvin Sextro 2022-01-10 04:19:41 +01:00
parent d205444659
commit 7d930105d2
1 changed files with 3 additions and 1 deletions

View File

@ -13,6 +13,7 @@ function Pass(): JSX.Element {
const [fragment, setFragment] = useState<string>(undefined);
const [view, setView] = useState<boolean>(true);
const [resized, setResized] = useState<boolean>(false);
useEffect(() => {
const rawFragment = window.location.hash.substring(1);
@ -22,12 +23,13 @@ function Pass(): JSX.Element {
}
const resizeTimeout = window.setTimeout(() => {
if (rawFragment) {
if (!resized && rawFragment) {
window.location.replace('/pass/note');
}
}, 100);
window.addEventListener('resize', () => {
setResized(true);
clearTimeout(resizeTimeout);
const decodedFragment = Buffer.from(rawFragment, 'base64').toString();
setFragment(decodedFragment);