mirror of
https://github.com/open-webui/open-webui
synced 2025-05-24 06:44:24 +00:00
Merge pull request #10634 from sebdanielsson/handle-no-location-access
fix: Handle no location permission
This commit is contained in:
commit
b77937dfad
@ -74,7 +74,13 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (command.content.includes('{{USER_LOCATION}}')) {
|
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));
|
text = text.replaceAll('{{USER_LOCATION}}', String(location));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -279,9 +279,9 @@ export const generateInitialsImage = (name) => {
|
|||||||
const initials =
|
const initials =
|
||||||
sanitizedName.length > 0
|
sanitizedName.length > 0
|
||||||
? sanitizedName[0] +
|
? sanitizedName[0] +
|
||||||
(sanitizedName.split(' ').length > 1
|
(sanitizedName.split(' ').length > 1
|
||||||
? sanitizedName[sanitizedName.lastIndexOf(' ') + 1]
|
? sanitizedName[sanitizedName.lastIndexOf(' ') + 1]
|
||||||
: '')
|
: '')
|
||||||
: '';
|
: '';
|
||||||
|
|
||||||
ctx.fillText(initials.toUpperCase(), canvas.width / 2, canvas.height / 2);
|
ctx.fillText(initials.toUpperCase(), canvas.width / 2, canvas.height / 2);
|
||||||
@ -348,10 +348,10 @@ export const compareVersion = (latest, current) => {
|
|||||||
return current === '0.0.0'
|
return current === '0.0.0'
|
||||||
? false
|
? false
|
||||||
: current.localeCompare(latest, undefined, {
|
: current.localeCompare(latest, undefined, {
|
||||||
numeric: true,
|
numeric: true,
|
||||||
sensitivity: 'case',
|
sensitivity: 'case',
|
||||||
caseFirst: 'upper'
|
caseFirst: 'upper'
|
||||||
}) < 0;
|
}) < 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
export const findWordIndices = (text) => {
|
export const findWordIndices = (text) => {
|
||||||
@ -846,6 +846,9 @@ export const promptTemplate = (
|
|||||||
if (user_location) {
|
if (user_location) {
|
||||||
// Replace {{USER_LOCATION}} in the template with the current location
|
// Replace {{USER_LOCATION}} in the template with the current location
|
||||||
template = template.replace('{{USER_LOCATION}}', user_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;
|
return template;
|
||||||
|
Loading…
Reference in New Issue
Block a user