mirror of
https://git.rezel.net/LudoTech/traque.git
synced 2026-04-11 00:30:19 +02:00
Fix photos + API hooks + cleaning
This commit is contained in:
@@ -1,18 +1,16 @@
|
||||
// React
|
||||
import { createContext, useContext, useMemo } from "react";
|
||||
// IO
|
||||
import { io } from "socket.io-client";
|
||||
// Util
|
||||
import { SOCKET_URL } from "../util/constants";
|
||||
|
||||
const IP = "172.16.1.180";
|
||||
const SOCKET_URL = `ws://${IP}/player`;
|
||||
const SERVER_URL = `http://${IP}/back`;
|
||||
const SocketContext = createContext();
|
||||
|
||||
export const teamSocket = io(SOCKET_URL, {
|
||||
path: "/back/socket.io",
|
||||
});
|
||||
|
||||
export const SocketContext = createContext();
|
||||
const teamSocket = io(SOCKET_URL, {path: "/back/socket.io"});
|
||||
|
||||
export const SocketProvider = ({ children }) => {
|
||||
const value = useMemo(() => ({ teamSocket, SERVER_URL }), []);
|
||||
const value = useMemo(() => ({ teamSocket }), []);
|
||||
|
||||
return (
|
||||
<SocketContext.Provider value={value}>{children}</SocketContext.Provider>
|
||||
|
||||
@@ -1,22 +1,22 @@
|
||||
// React
|
||||
import { createContext, useContext, useMemo } from "react";
|
||||
import { useSocket } from "./socketContext";
|
||||
// Hook
|
||||
import { useSocketAuth } from "../hook/useSocketAuth";
|
||||
|
||||
const teamConnexionContext = createContext();
|
||||
const TeamConnexionContext = createContext();
|
||||
|
||||
export const TeamConnexionProvider = ({ children }) => {
|
||||
const { teamSocket } = useSocket();
|
||||
const { login, password: teamId, loggedIn, loading, logout } = useSocketAuth(teamSocket, "team_password");
|
||||
const { login, password: teamId, loggedIn, logout } = useSocketAuth();
|
||||
|
||||
const value = useMemo(() => ({ teamId, login, logout, loggedIn, loading}), [teamId, login, logout, loggedIn, loading]);
|
||||
const value = useMemo(() => ({ teamId, login, logout, loggedIn}), [teamId, login, logout, loggedIn]);
|
||||
|
||||
return (
|
||||
<teamConnexionContext.Provider value={value}>
|
||||
<TeamConnexionContext.Provider value={value}>
|
||||
{children}
|
||||
</teamConnexionContext.Provider>
|
||||
</TeamConnexionContext.Provider>
|
||||
);
|
||||
};
|
||||
|
||||
export const useTeamConnexion = () => {
|
||||
return useContext(teamConnexionContext);
|
||||
return useContext(TeamConnexionContext);
|
||||
};
|
||||
|
||||
@@ -1,12 +1,16 @@
|
||||
// React
|
||||
import { createContext, useContext, useMemo, useState } from "react";
|
||||
// Context
|
||||
import { useSocket } from "./socketContext";
|
||||
import { useTeamConnexion } from "./teamConnexionContext";
|
||||
import { GameState } from "../util/gameState";
|
||||
// Hook
|
||||
import { useSendDeviceInfo } from "../hook/useSendDeviceInfo";
|
||||
import { useLocation } from "../hook/useLocation";
|
||||
import { useSocketListener } from "../hook/useSocketListener";
|
||||
// Util
|
||||
import { GameState } from "../util/gameState";
|
||||
|
||||
const teamContext = createContext();
|
||||
const TeamContext = createContext();
|
||||
|
||||
export const TeamProvider = ({children}) => {
|
||||
const {teamSocket} = useSocket();
|
||||
@@ -51,18 +55,17 @@ export const TeamProvider = ({children}) => {
|
||||
|
||||
useSocketListener(teamSocket, "logout", logout);
|
||||
|
||||
|
||||
const value = useMemo(() => (
|
||||
{teamInfos, gameState, startDate, zoneType, zoneExtremities, nextZoneDate, messages, location, getLocationAuthorization, startLocationTracking, stopLocationTracking}
|
||||
), [teamInfos, gameState, startDate, zoneType, zoneExtremities, nextZoneDate, messages, location, getLocationAuthorization, startLocationTracking, stopLocationTracking]);
|
||||
|
||||
return (
|
||||
<teamContext.Provider value={value}>
|
||||
<TeamContext.Provider value={value}>
|
||||
{children}
|
||||
</teamContext.Provider>
|
||||
</TeamContext.Provider>
|
||||
);
|
||||
};
|
||||
|
||||
export const useTeamContext = () => {
|
||||
return useContext(teamContext);
|
||||
return useContext(TeamContext);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user