mirror of
https://github.com/orangecoding/fredy.git
synced 2026-06-16 12:31:07 +00:00
improved tooltip in map, improved user-settings handling
This commit is contained in:
@@ -90,15 +90,25 @@ export function upsertSettings(settingsMapOrEntry, userId = null) {
|
||||
: Object.entries(settingsMapOrEntry || {});
|
||||
|
||||
for (const [name, rawValue] of entries) {
|
||||
const id = nanoid();
|
||||
const create_date = Date.now();
|
||||
const json = toJson(rawValue === null ? 'null' : rawValue);
|
||||
SqliteConnection.execute(
|
||||
`INSERT INTO settings (id, create_date, name, value, user_id)
|
||||
if (rawValue === null) {
|
||||
SqliteConnection.execute(
|
||||
`DELETE FROM settings WHERE name = @name AND (user_id = @userId OR (user_id IS NULL AND @userId IS NULL))`,
|
||||
{
|
||||
name,
|
||||
userId,
|
||||
},
|
||||
);
|
||||
} else {
|
||||
const id = nanoid();
|
||||
const create_date = Date.now();
|
||||
const json = toJson(rawValue);
|
||||
SqliteConnection.execute(
|
||||
`INSERT INTO settings (id, create_date, name, value, user_id)
|
||||
VALUES (@id, @create_date, @name, @value, @userId)
|
||||
ON CONFLICT(name, IFNULL(user_id, 'GLOBAL_SETTING')) DO UPDATE SET value = excluded.value`,
|
||||
{ id, create_date, name, value: json, userId },
|
||||
);
|
||||
{ id, create_date, name, value: json, userId },
|
||||
);
|
||||
}
|
||||
}
|
||||
// keep cache in sync (only for global settings)
|
||||
if (userId == null) {
|
||||
|
||||
@@ -95,7 +95,7 @@ function isOneOf(word, arr) {
|
||||
* @returns {boolean}
|
||||
*/
|
||||
function nullOrEmpty(val) {
|
||||
return val == null || val.length === 0 || val === 'null' || val === 'undefined';
|
||||
return val == null || val.length === 0;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -18,6 +18,7 @@ import RangeSlider from 'react-range-slider-input';
|
||||
import 'react-range-slider-input/dist/style.css';
|
||||
import './Map.less';
|
||||
import { xhrDelete } from '../../services/xhr.js';
|
||||
import { Link } from 'react-router';
|
||||
|
||||
const { Text } = Typography;
|
||||
|
||||
@@ -503,7 +504,12 @@ export default function MapView() {
|
||||
type="warning"
|
||||
bordered
|
||||
closeIcon={null}
|
||||
description="You have not set your home address yet. Please do so in the settings to use the distance filter."
|
||||
description={
|
||||
<span>
|
||||
You have not set your home address yet. Please do so in the <Link to="/userSettings">user settings</Link>{' '}
|
||||
to use the distance filter.
|
||||
</span>
|
||||
}
|
||||
/>
|
||||
)}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user