Moving invitation check in its own module

This commit is contained in:
Eric van der Vlist 2023-03-04 09:23:28 +01:00
parent bedcaa209a
commit 5ad98a860e
3 changed files with 39 additions and 24 deletions

View File

@ -0,0 +1,36 @@
import { Component, createSignal } from 'solid-js';
interface props {}
const [invitation, setInvitation] = createSignal<any>(false);
export const searchInvitation = () => {
const hash = location.hash;
console.log({ caller: 'Invitation / searchInvitation', hash });
if (hash.length > 1) {
try {
const payload = hash.slice(1);
const decoded = atob(payload);
const url = new URL(decoded);
setInvitation(url);
console.log({
caller: 'Invitation / searchInvitation',
hash,
invitation: decoded,
});
} catch {
console.warn({
caller: 'Invitation / searchInvitation',
hash,
message: 'Hash is not a base64 encoded URL',
});
}
}
};
const Invitation: Component<props> = (props) => {
return <></>;
};
export default Invitation;

View File

@ -0,0 +1 @@
export { default, searchInvitation } from './Invitation';

View File

@ -46,6 +46,7 @@ import { Overlays } from '../overlays/Overlays';
import Finder, { findLocation } from '../finder'; import Finder, { findLocation } from '../finder';
import { ZoomIn } from '@suid/icons-material'; import { ZoomIn } from '@suid/icons-material';
import Note from '../note'; import Note from '../note';
import { searchInvitation } from '../invitation';
const [getState, setState] = createSignal({ const [getState, setState] = createSignal({
lon: 0, lon: 0,
@ -67,30 +68,7 @@ const Map: Component = () => {
const navigate = useNavigate(); const navigate = useNavigate();
const params = useParams(); const params = useParams();
const hash = location.hash; searchInvitation();
console.log({ caller: 'Map / hash', hash });
const [invitation, setInvitation] = createSignal<any>(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 // See https://stackoverflow.com/questions/71288670/how-to-make-fullscreen-ionic-capacitor-app
AndroidFullScreen.isImmersiveModeSupported() AndroidFullScreen.isImmersiveModeSupported()