Compare commits

..

No commits in common. "256f0b768407eefa94274a501b0ed49799cdc428" and "0433e4695eefd6ea064bba494455148120eb8e11" have entirely different histories.

6 changed files with 9 additions and 15 deletions

View File

@ -1,4 +1,3 @@
import { Constants } from '@/constants/Constants'
import { useAuth } from '@/hooks/useAuth' import { useAuth } from '@/hooks/useAuth'
import { useChallengeActions, useDownloadChallengeActions } from '@/hooks/useChallengeActions' import { useChallengeActions, useDownloadChallengeActions } from '@/hooks/useChallengeActions'
import { useDownloadChallenges } from '@/hooks/useChallenges' import { useDownloadChallenges } from '@/hooks/useChallenges'
@ -32,7 +31,7 @@ export default function GameProvider({ children }: { children: ReactNode }) {
headers: { "Authorization": `Bearer ${auth.token}` }} headers: { "Authorization": `Bearer ${auth.token}` }}
).then(resp => resp.json()), ).then(resp => resp.json()),
enabled: isAuthValid(auth), enabled: isAuthValid(auth),
refetchInterval: Constants.QUERY_REFETCH_INTERVAL * 1000, refetchInterval: 5000,
}) })
useEffect(() => { useEffect(() => {
if (gameQuery.isSuccess && gameQuery.data) if (gameQuery.isSuccess && gameQuery.data)
@ -45,7 +44,7 @@ export default function GameProvider({ children }: { children: ReactNode }) {
headers: { "Authorization": `Bearer ${auth.token}` }} headers: { "Authorization": `Bearer ${auth.token}` }}
).then(resp => resp.json()), ).then(resp => resp.json()),
enabled: isAuthValid(auth) && !!game.playerId, enabled: isAuthValid(auth) && !!game.playerId,
refetchInterval: Constants.QUERY_REFETCH_INTERVAL * 1000, refetchInterval: 5000,
}) })
useEffect(() => { useEffect(() => {
if (playerQuery.isSuccess && playerQuery.data) { if (playerQuery.isSuccess && playerQuery.data) {
@ -61,7 +60,7 @@ export default function GameProvider({ children }: { children: ReactNode }) {
).then(resp => resp.json()), ).then(resp => resp.json()),
enabled: isAuthValid(auth) && !!game.playerId, enabled: isAuthValid(auth) && !!game.playerId,
initialData: { data: [], meta: { currentPage: 0, lastPage: 0, nextPage: 0, prevPage: 0, total: 0, totalPerPage: 0 } }, initialData: { data: [], meta: { currentPage: 0, lastPage: 0, nextPage: 0, prevPage: 0, total: 0, totalPerPage: 0 } },
refetchInterval: Constants.QUERY_REFETCH_INTERVAL * 1000, refetchInterval: 5000,
}) })
useEffect(() => { useEffect(() => {
if (trainsQuery.isSuccess && trainsQuery.data) if (trainsQuery.isSuccess && trainsQuery.data)
@ -75,7 +74,7 @@ export default function GameProvider({ children }: { children: ReactNode }) {
).then(resp => resp.json()), ).then(resp => resp.json()),
enabled: isAuthValid(auth), enabled: isAuthValid(auth),
initialData: { data: [], meta: { currentPage: 0, lastPage: 0, nextPage: 0, prevPage: 0, total: 0, totalPerPage: 0 } }, initialData: { data: [], meta: { currentPage: 0, lastPage: 0, nextPage: 0, prevPage: 0, total: 0, totalPerPage: 0 } },
refetchInterval: Constants.QUERY_REFETCH_INTERVAL * 1000, refetchInterval: 5000,
}) })
useEffect(() => { useEffect(() => {
if (challengesQuery.isSuccess && challengesQuery.data) { if (challengesQuery.isSuccess && challengesQuery.data) {
@ -92,7 +91,7 @@ export default function GameProvider({ children }: { children: ReactNode }) {
headers: { "Authorization": `Bearer ${auth.token}` }} headers: { "Authorization": `Bearer ${auth.token}` }}
).then(resp => resp.json()), ).then(resp => resp.json()),
enabled: isAuthValid(auth) && !!game.playerId, enabled: isAuthValid(auth) && !!game.playerId,
refetchInterval: Constants.QUERY_REFETCH_INTERVAL * 1000, refetchInterval: 5000,
}) })
useEffect(() => { useEffect(() => {
if (moneyUpdatesQuery.isSuccess && moneyUpdatesQuery.data) if (moneyUpdatesQuery.isSuccess && moneyUpdatesQuery.data)

View File

@ -8,7 +8,6 @@ import { useQuery } from '@tanstack/react-query'
import { isAuthValid } from '@/utils/features/auth/authSlice' import { isAuthValid } from '@/utils/features/auth/authSlice'
import { socket } from '@/utils/socket' import { socket } from '@/utils/socket'
import { PlayerLocation } from '@/utils/features/location/locationSlice' import { PlayerLocation } from '@/utils/features/location/locationSlice'
import { Constants } from '@/constants/Constants'
export default function GeolocationProvider({ children }: { children: ReactNode }) { export default function GeolocationProvider({ children }: { children: ReactNode }) {
useStartGeolocationServiceEffect() useStartGeolocationServiceEffect()
@ -44,7 +43,7 @@ export default function GeolocationProvider({ children }: { children: ReactNode
}).then(resp => resp.json()), }).then(resp => resp.json()),
initialData: [], initialData: [],
enabled: isAuthValid(auth), enabled: isAuthValid(auth),
refetchInterval: Constants.QUERY_REFETCH_INTERVAL * 1000, refetchInterval: 5000,
}) })
useEffect(() => { useEffect(() => {
if (lastLocationsQuery.isSuccess && lastLocationsQuery.data) if (lastLocationsQuery.isSuccess && lastLocationsQuery.data)

View File

@ -1,4 +1,3 @@
export const Constants = { export const Constants = {
MIN_DELAY_LOCATION_SENT: 20, MIN_DELAY_LOCATION_SENT: 20
QUERY_REFETCH_INTERVAL: 15,
} }

View File

@ -1,5 +1,5 @@
import { io } from 'socket.io-client' import { io } from 'socket.io-client'
export const socket = io(process.env.EXPO_PUBLIC_TRAINTRAPE_MOI_SERVER, { export const socket = io("http://192.168.1.198:3000", {
reconnection: true, reconnection: true,
}) })

View File

@ -1,4 +1,3 @@
DATABASE_URL="postgres://username:password@localhost:5432/traintrape-moi" DATABASE_URL="postgres://username:password@localhost:5432/traintrape-moi"
JWT_SECRET="CHANGE_ME" JWT_SECRET="CHANGE_ME"
API_GLOBAL_PREFIX="api" API_GLOBAL_PREFIX="api"
API_HOSTNAME="traintrape-moi.luemy.eu"

View File

@ -1,9 +1,7 @@
import { SubscribeMessage, WebSocketGateway, WebSocketServer } from '@nestjs/websockets' import { SubscribeMessage, WebSocketGateway, WebSocketServer } from '@nestjs/websockets'
import { Server, Socket } from 'socket.io' import { Server, Socket } from 'socket.io'
@WebSocketGateway({ @WebSocketGateway()
cors: { allowedHeaders: process.env.API_HOSTNAME },
})
export class GeolocationsGateway { export class GeolocationsGateway {
@WebSocketServer() @WebSocketServer()
server: Server server: Server