Merge pull request #10634 from sebdanielsson/handle-no-location-access

fix: Handle no location permission
This commit is contained in:
Timothy Jaeryang Baek 2025-02-23 13:23:47 -08:00 committed by GitHub
commit b77937dfad
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 17 additions and 8 deletions

View File

@ -74,7 +74,13 @@
}
if (command.content.includes('{{USER_LOCATION}}')) {
const location = await getUserPosition();
let location;
try {
location = await getUserPosition();
} catch (error) {
toast.error($i18n.t('Location access not allowed'));
location = 'LOCATION_UNKNOWN';
}
text = text.replaceAll('{{USER_LOCATION}}', String(location));
}

View File

@ -846,6 +846,9 @@ export const promptTemplate = (
if (user_location) {
// Replace {{USER_LOCATION}} in the template with the current location
template = template.replace('{{USER_LOCATION}}', user_location);
} else {
// Replace {{USER_LOCATION}} in the template with 'Unknown' if no location is provided
template = template.replace('{{USER_LOCATION}}', 'LOCATION_UNKNOWN');
}
return template;