mirror of
https://github.com/inaturalist/iNaturalistReactNative.git
synced 2026-06-21 14:08:31 -04:00
Reject locations over a minute old
This commit is contained in:
@@ -10,6 +10,7 @@ import { useCallback, useEffect, useState } from "react";
|
||||
import { clearWatch, watchPosition } from "../sharedHelpers/geolocationWrapper";
|
||||
|
||||
export const TARGET_POSITIONAL_ACCURACY = 10;
|
||||
const MAX_POSITION_AGE_MS = 60_000;
|
||||
|
||||
interface UserLocation {
|
||||
latitude: number,
|
||||
@@ -39,6 +40,8 @@ const useWatchPosition = ( options: {
|
||||
const startWatch = ( ) => {
|
||||
setIsFetchingLocation( true );
|
||||
const success = ( position: GeolocationResponse ) => {
|
||||
const age = Date.now() - position.timestamp;
|
||||
if ( age > MAX_POSITION_AGE_MS ) return;
|
||||
setCurrentPosition( position );
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user