Compare commits
2
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e6f2448e94 | ||
|
|
39c65927ac |
No files matched your search
@@ -29,15 +29,24 @@ export default function PermissionCheck({
|
||||
const requestGPSPermission = () => {
|
||||
if (gpsStatus === "granted") return;
|
||||
setIsGPSPermissionLoading(true);
|
||||
|
||||
navigator.geolocation.getCurrentPosition((pos) => {
|
||||
setIsGPSPermissionLoading(false);
|
||||
refresh();
|
||||
}, (e) => {
|
||||
setIsGPSPermissionLoading(false);
|
||||
console.error("GPS Error Code:", e.code, "Message:", e.message);
|
||||
|
||||
if (e.code === 3) {
|
||||
alert("GPS-Timeout: Das Erfassen des Standorts hat zu lange gedauert. Bitte im Freien erneut versuchen.");
|
||||
} else if (e.code === 1) {
|
||||
alert("GPS-Berechtigung verweigert. Bitte in den Safari-Einstellungen für diese Website erlauben.");
|
||||
}
|
||||
refresh();
|
||||
}, {
|
||||
enableHighAccuracy: true,
|
||||
timeout: 3000
|
||||
timeout: 15000,
|
||||
maximumAge: 0
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -20,6 +20,7 @@ import { fetchRiddleData, getRiddleData, setRiddleData } from "@/utils/riddledat
|
||||
import { heartbeat } from "@/utils/sessionHandler";
|
||||
import { getCompletedRiddles } from "@/utils/completedRiddles";
|
||||
import { isDemoMode } from "@/utils/demoMode";
|
||||
import { addReachedRiddle, getReachedRiddles } from "@/utils/reachedRiddles";
|
||||
|
||||
export default function Tour() {
|
||||
const [ demoModeStr, ] = useLocalStorage(PREF.demo_mode, "");
|
||||
@@ -91,6 +92,11 @@ export default function Tour() {
|
||||
const [ boughtHintsStr, ] = useLocalStorage(PREF.bought_hints, "");
|
||||
const [ playerCountStr, ] = useLocalStorage(PREF.player_count, "");
|
||||
const [ voiceOverStr, ] = useLocalStorage(PREF.voice_over, "");
|
||||
const [ reachedRiddlesStr, ] = useLocalStorage(PREF.reached_riddles, "");
|
||||
|
||||
const reachedRiddles = useMemo(() => {
|
||||
return getReachedRiddles();
|
||||
}, [reachedRiddlesStr]);
|
||||
|
||||
const permissionsGranted = gpsStatus === "granted" && cameraStatus === "granted";
|
||||
|
||||
@@ -121,7 +127,8 @@ export default function Tour() {
|
||||
"completed_riddles": completedRiddlesStr,
|
||||
"points": pointsStr,
|
||||
"bought_hints": boughtHintsStr,
|
||||
"voice_over": voiceOverStr
|
||||
"voice_over": voiceOverStr,
|
||||
"reached_riddles": reachedRiddlesStr,
|
||||
}, code);
|
||||
// TODO: Check if Code is valid.
|
||||
};
|
||||
@@ -190,9 +197,13 @@ export default function Tour() {
|
||||
|
||||
const distanceMeters = userLngLat.distanceTo(markerLngLat);
|
||||
const isNearby = distanceMeters <= r.requiredDistance;
|
||||
const reachedAlready = reachedRiddles.includes(r.step);
|
||||
|
||||
if (isNearby || demoMode) {
|
||||
if (isNearby || demoMode || reachedAlready) {
|
||||
setClickedMarker(marker.id);
|
||||
if (!reachedAlready) {
|
||||
addReachedRiddle(r.step);
|
||||
}
|
||||
} else {
|
||||
setShowTooFar(true);
|
||||
}
|
||||
|
||||
@@ -10,6 +10,7 @@ export enum PREF {
|
||||
voice_over = "PREF_VOICEOVER_STATE",
|
||||
bought_hints = "PREF_BOUGHT_HINTS",
|
||||
demo_mode = "PREF_DEMO_MODE",
|
||||
reached_riddles = "PREF_REACHED_RIDDLES",
|
||||
};
|
||||
|
||||
const isDev = process.env.NODE_ENV === "development";
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
import { PREF } from "./const";
|
||||
|
||||
export function addReachedRiddle(step: number) {
|
||||
const riddles = getReachedRiddles();
|
||||
if (riddles.includes(step)) {
|
||||
return;
|
||||
}
|
||||
riddles.push(step);
|
||||
localStorage.setItem(PREF.reached_riddles, JSON.stringify(riddles));
|
||||
window.dispatchEvent(new Event('storage'));
|
||||
}
|
||||
|
||||
export function getReachedRiddles(): number[] {
|
||||
const riddleList = localStorage.getItem(PREF.reached_riddles);
|
||||
if (riddleList === null || riddleList.length < 1) {
|
||||
return [];
|
||||
}
|
||||
return JSON.parse(riddleList);
|
||||
}
|
||||
@@ -8,6 +8,7 @@ interface SessionData {
|
||||
"points": string;
|
||||
"bought_hints": string;
|
||||
"voice_over": string;
|
||||
"reached_riddles": string;
|
||||
};
|
||||
|
||||
export async function heartbeat(data: SessionData, code: string) {
|
||||
@@ -29,6 +30,7 @@ export function setSessionData(data: SessionData) {
|
||||
localStorage.setItem(PREF.points, data.points);
|
||||
localStorage.setItem(PREF.bought_hints, data.bought_hints);
|
||||
localStorage.setItem(PREF.voice_over, data.voice_over);
|
||||
localStorage.setItem(PREF.reached_riddles, data.reached_riddles);
|
||||
}
|
||||
|
||||
export async function finishSession(code: string): Promise<Response> {
|
||||
|
||||
Reference in new issue
Block a user