mirror of
https://github.com/umami-software/umami.git
synced 2026-02-07 22:27:16 +01:00
Updated profile settings. Refactored locale saving.
This commit is contained in:
parent
814589f6a5
commit
7f598fa84d
9 changed files with 82 additions and 30 deletions
15
lib/web.js
15
lib/web.js
|
|
@ -19,7 +19,7 @@ export const apiRequest = (method, url, body) =>
|
|||
return null;
|
||||
});
|
||||
|
||||
function parseQuery(url, params = {}) {
|
||||
const parseQuery = (url, params = {}) => {
|
||||
const query = Object.keys(params).reduce((values, key) => {
|
||||
if (params[key] !== undefined) {
|
||||
return values.concat(`${key}=${encodeURIComponent(params[key])}`);
|
||||
|
|
@ -27,7 +27,7 @@ function parseQuery(url, params = {}) {
|
|||
return values;
|
||||
}, []);
|
||||
return query.length ? `${url}?${query.join('&')}` : url;
|
||||
}
|
||||
};
|
||||
|
||||
export const get = (url, params) => apiRequest('get', parseQuery(url, params));
|
||||
|
||||
|
|
@ -62,3 +62,14 @@ export const doNotTrack = () => {
|
|||
|
||||
return dnt === true || dnt === 1 || dnt === 'yes' || dnt === '1';
|
||||
};
|
||||
|
||||
export const setItem = (key, data, session) => {
|
||||
if (typeof window !== 'undefined') {
|
||||
(session ? sessionStorage : localStorage).setItem(key, JSON.stringify(data));
|
||||
}
|
||||
};
|
||||
|
||||
export const getItem = (key, session) =>
|
||||
typeof window !== 'undefined'
|
||||
? JSON.parse((session ? sessionStorage : localStorage).getItem(key))
|
||||
: null;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue