25 lines
1.2 KiB
TypeScript
25 lines
1.2 KiB
TypeScript
import { LocationObject } from "expo-location"
|
|
import { useAppDispatch, useAppSelector } from "./useStore"
|
|
import { PlayerLocation, setLastLocation, setLastPlayerLocation, setLastPlayerLocations, unqueueLocation } from "@/utils/features/location/locationSlice"
|
|
|
|
export const useLastOwnLocation = () => useAppSelector((state) => state.location.lastOwnLocation)
|
|
export const useQueuedLocations = () => useAppSelector((state) => state.location.queuedLocations)
|
|
export const useLastPlayerLocations = () => useAppSelector((state) => state.location.lastPlayerLocations)
|
|
|
|
export const useSetLastLocation = () => {
|
|
const dispatch = useAppDispatch()
|
|
return (location: LocationObject) => dispatch(setLastLocation(location))
|
|
}
|
|
export const useUnqueueLocation = () => {
|
|
const dispatch = useAppDispatch()
|
|
return (location: LocationObject) => dispatch(unqueueLocation(location))
|
|
}
|
|
export const useSetLastPlayerLocations = () => {
|
|
const dispatch = useAppDispatch()
|
|
return (playerLocations: PlayerLocation[]) => dispatch(setLastPlayerLocations(playerLocations))
|
|
}
|
|
export const useSetLastPlayerLocation = () => {
|
|
const dispatch = useAppDispatch()
|
|
return (playerLocation: PlayerLocation) => dispatch(setLastPlayerLocation(playerLocation))
|
|
}
|