R7, R2, Heartbeat, Sessions, Code, cleanup, Outro
This commit is contained in:
1 parent
b5e5cc502d
commit
5b9fe3ea21
25 files changed
+346
-116
No files matched your search
@@ -1,7 +1,17 @@
|
||||
import { API_PREFIX } from "./const";
|
||||
import { API_PREFIX, HTTP_SCHEME, PREF } from "./const";
|
||||
|
||||
export async function heartbeat(data: any, code: string) {
|
||||
const res = await fetch(`${API_PREFIX}/sessions?code=${code}`,
|
||||
interface SessionData {
|
||||
"player_count": string;
|
||||
"players": string;
|
||||
"worthy_answers": string;
|
||||
"completed_riddles": string;
|
||||
"points": string;
|
||||
"bought_hints": string;
|
||||
"voice_over": string;
|
||||
};
|
||||
|
||||
export async function heartbeat(data: SessionData, code: string) {
|
||||
const res = await fetch(`${HTTP_SCHEME}://${API_PREFIX}/sessions?code=${code}`,
|
||||
{
|
||||
"method": "POST",
|
||||
"cache": "no-cache",
|
||||
@@ -9,4 +19,14 @@ export async function heartbeat(data: any, code: string) {
|
||||
}
|
||||
);
|
||||
return res;
|
||||
}
|
||||
|
||||
export function setSessionData(data: SessionData) {
|
||||
localStorage.setItem(PREF.playerCount, data.player_count);
|
||||
localStorage.setItem(PREF.players, data.players);
|
||||
localStorage.setItem(PREF.worthyWords, data.worthy_answers);
|
||||
localStorage.setItem(PREF.completed_riddles, data.completed_riddles);
|
||||
localStorage.setItem(PREF.points, data.points);
|
||||
localStorage.setItem(PREF.boughtHints, data.bought_hints);
|
||||
localStorage.setItem(PREF.voiceover, data.voice_over);
|
||||
}
|
||||
Reference in new issue
Block a user