diff --git a/lib/services/storage/settingsStorage.js b/lib/services/storage/settingsStorage.js index def3d44..5f09fbc 100644 --- a/lib/services/storage/settingsStorage.js +++ b/lib/services/storage/settingsStorage.js @@ -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) { diff --git a/lib/utils.js b/lib/utils.js index 8a00f74..692b03d 100755 --- a/lib/utils.js +++ b/lib/utils.js @@ -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; } /** diff --git a/ui/src/views/listings/Map.jsx b/ui/src/views/listings/Map.jsx index 2c9587d..b61566e 100644 --- a/ui/src/views/listings/Map.jsx +++ b/ui/src/views/listings/Map.jsx @@ -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={ + + You have not set your home address yet. Please do so in the user settings{' '} + to use the distance filter. + + } /> )}