Closed lanitochka17 closed 1 week ago
Triggered auto assignment to @anmurali (Bug
), see https://stackoverflow.com/c/expensify/questions/14418 for more details. Please add this bug to a GH project, as outlined in the SO.
@anmurali FYI I haven't added the External label as I wasn't 100% sure about this issue. Please take a look and add the label if you agree it's a bug and can be handled by external contributors
Clearing cache doesn't seem to reset the users location. Users location is saved in Onyx(local database) I think. Let me know the answer.
We do not have a logic to clear the userLocation
(stored in onyx) when the location permission is not granted in MapView component.
We should add a logic to clear the userLocation
if the location permission is not granted to this file:
useEffect(() => {
const checkPermission = async () => {
const permissionStatus = await navigator.permissions.query({name: 'geolocation'});
if (permissionStatus.state !== 'granted') {
UserLocation.clearUserLocation();
}
};
checkPermission();
}, []);
In above, we can use permissionStatus.state === 'prompt'
instead of permissionStatus.state !== 'granted'
.
We should apply the fix in native platform as well:
const checkPermission = async () => {
try {
let permissionStatus;
if (Platform.OS === 'ios') {
permissionStatus = await check(PERMISSIONS.IOS.LOCATION_WHEN_IN_USE);
} else if (Platform.OS === 'android') {
permissionStatus = await PermissionsAndroid.check(PermissionsAndroid.PERMISSIONS.ACCESS_FINE_LOCATION);
}
if (permissionStatus !== RESULTS.GRANTED) {
UserLocation.clearUserLocation();
}
} catch (err) {
console.warn(err);
}
};
useEffect(() => {
checkPermission();
}, []);
We can create an event listener to the permission location. Once it changes to not granted
, call UserLocation.clearUserLocation()
. Below is pseudo code:
useEffect(() => {
let permissionStatus;
const checkPermission = async () => {
try {
permissionStatus = await navigator.permissions.query({ name: 'geolocation' });
if (permissionStatus.state !== 'granted') {
UserLocation.clearUserLocation();
}
} catch (err) {
console.error(err);
}
};
// Initial permission check
checkPermission();
// Event listener for permission changes
const handlePermissionChange = () => {
if (permissionStatus.state !== 'granted') {
UserLocation.clearUserLocation();
}
};
permissionStatus.addEventListener('change', handlePermissionChange);
// Clean up event listener on component unmount
return () => {
if (permissionStatus) {
permissionStatus.removeEventListener('change', handlePermissionChange);
}
};
}, []);
@anmurali Uh oh! This issue is overdue by 2 days. Don't forget to update your issues!
@anmurali Still overdue 6 days?! Let's take care of this!
Hmm I cannot reproduce. Map does go back to centering in SF. I am also not sure why this is an issue? It doesn't seem like a problem if it doesn't actually behave this way.
@anmurali
https://github.com/user-attachments/assets/bd881af2-f60a-48fe-9a25-d86c10a4a086
If you haven’t already, check out our contributing guidelines for onboarding and email contributors@expensify.com to request to join our Slack channel!
Version Number: 9.0.5-2 Reproducible in staging?: Y Reproducible in production?: Y If this was caught during regression testing, add the test name, ID and link from TestRail: https://expensify.testrail.io/index.php?/tests/view/4700585 Issue reported by: Applause - Internal Team
Action Performed:
Expected Result:
Map should center on San Francisco
Actual Result:
Map centers on user's current location based on the saved cache but if user clears cache and restarts then map centers on San Francisco
Workaround:
Unknown
Platforms:
Which of our officially supported platforms is this issue occurring on?
Screenshots/Videos
Add any screenshot/video evidence
https://github.com/Expensify/App/assets/78819774/87a55c1f-1fb6-4e55-8206-88f212f16e76
View all open jobs on GitHub