From bedcaa209a064940ce698efbe731e3ae6e02ceba Mon Sep 17 00:00:00 2001 From: evlist Date: Fri, 3 Mar 2023 21:39:26 +0100 Subject: [PATCH] Checking if location's hash contains an invitation --- src/components/map/Map.tsx | 31 +++++++++++++++++++++++++------ 1 file changed, 25 insertions(+), 6 deletions(-) diff --git a/src/components/map/Map.tsx b/src/components/map/Map.tsx index 9fdfe05..9d4310f 100644 --- a/src/components/map/Map.tsx +++ b/src/components/map/Map.tsx @@ -63,15 +63,34 @@ const [getMap, setMap] = createSignal(null); export { getMap }; -const useHash = () => useLocation().hash; - const Map: Component = () => { const navigate = useNavigate(); const params = useParams(); - createEffect(() => { - console.log({ caller: 'Map / createEffect', hash: useHash() }); - }); + const hash = location.hash; + console.log({ caller: 'Map / hash', hash }); + + const [invitation, setInvitation] = createSignal(false); + + if (hash.length > 1) { + try { + const payload = hash.slice(1); + const decoded = atob(payload); + const url = new URL(decoded); + setInvitation(url); + console.log({ + caller: 'Map', + hash, + invitation: decoded, + }); + } catch { + console.warn({ + caller: 'Map', + hash, + message: 'Hash is not a base64 encoded URL', + }); + } + } // See https://stackoverflow.com/questions/71288670/how-to-make-fullscreen-ionic-capacitor-app AndroidFullScreen.isImmersiveModeSupported() @@ -296,7 +315,7 @@ const Map: Component = () => { return ( // // @ts-ignore -
+