Affichage des dernières positions sur la carte
This commit is contained in:
@ -2,16 +2,30 @@ import { Constants } from '@/constants/Constants'
|
||||
import { createSlice, PayloadAction } from '@reduxjs/toolkit'
|
||||
import { LocationObject } from 'expo-location'
|
||||
|
||||
export type PlayerLocation = {
|
||||
id: number
|
||||
playerId: number
|
||||
longitude: number
|
||||
latitude: number
|
||||
speed: number
|
||||
accuracy: number
|
||||
altitude: number
|
||||
altitudeAccuracy: number
|
||||
timestamp: string
|
||||
}
|
||||
|
||||
interface LocationState {
|
||||
lastOwnLocation: LocationObject | null
|
||||
lastSentLocation: LocationObject | null
|
||||
queuedLocations: LocationObject[]
|
||||
lastPlayerLocations: PlayerLocation[]
|
||||
}
|
||||
|
||||
const initialState: LocationState = {
|
||||
lastOwnLocation: null,
|
||||
lastSentLocation: null,
|
||||
queuedLocations: []
|
||||
queuedLocations: [],
|
||||
lastPlayerLocations: []
|
||||
}
|
||||
|
||||
export const locationSlice = createSlice({
|
||||
@ -33,9 +47,12 @@ export const locationSlice = createSlice({
|
||||
|| loc.coords.latitude !== sentLoc.coords.latitude
|
||||
|| loc.coords.longitude !== sentLoc.coords.latitude)
|
||||
},
|
||||
setLastPlayerLocations: (state, action: PayloadAction<PlayerLocation[]>) => {
|
||||
state.lastPlayerLocations = action.payload
|
||||
}
|
||||
},
|
||||
})
|
||||
|
||||
export const { setLastLocation, unqueueLocation } = locationSlice.actions
|
||||
export const { setLastLocation, unqueueLocation, setLastPlayerLocations } = locationSlice.actions
|
||||
|
||||
export default locationSlice.reducer
|
||||
|
Reference in New Issue
Block a user