mirror of
https://github.com/cpvalente/ontime.git
synced 2026-08-08 00:43:54 +00:00
f1538def99
- add settings atom with cursor mode - in locked mode eventlist scrolls to cursor - cleanup unused menu items
35 lines
838 B
JavaScript
35 lines
838 B
JavaScript
const { atom } = require('jotai');
|
|
|
|
const PATH = 'option-gen';
|
|
const initialValue = {
|
|
cursor: 'locked',
|
|
};
|
|
|
|
export const settingsAtom = atom(
|
|
(get) => {
|
|
const storedOptions = localStorage.getItem(PATH);
|
|
if (storedOptions == null) return initialValue;
|
|
|
|
return JSON.parse(storedOptions);
|
|
},
|
|
(get, set, newValues) => {
|
|
set(settingsAtom, newValues);
|
|
localStorage.setItem(PATH, JSON.stringify(newValues));
|
|
}
|
|
);
|
|
|
|
// get a single option, if it exists
|
|
export const SelectSetting = (setting) => {
|
|
return atom((get) => get(settingsAtom)[setting]);
|
|
};
|
|
|
|
// change a single item in object
|
|
export const HandleOptions = atom(null, (get, set, payload) => {
|
|
const updatedVal = {
|
|
...get(settingsAtom),
|
|
...payload,
|
|
};
|
|
set(settingsAtom, updatedVal);
|
|
localStorage.setItem(PATH, JSON.stringify(updatedVal));
|
|
});
|