copmuted settings
This commit is contained in:
parent
139b5376fc
commit
784b9c08ec
1 changed files with 8 additions and 5 deletions
|
|
@ -2,6 +2,7 @@ import { persistentMap } from '@nanostores/persistent';
|
|||
import { useStore } from '@nanostores/react';
|
||||
import { register } from '@strudel/core';
|
||||
import { isUdels } from './repl/util.mjs';
|
||||
import { computed } from 'nanostores';
|
||||
|
||||
export const audioEngineTargets = {
|
||||
webaudio: 'webaudio',
|
||||
|
|
@ -64,11 +65,7 @@ const settings_key = `strudel-settings${instance > 0 ? instance : ''}`;
|
|||
|
||||
export const settingsMap = persistentMap(settings_key, defaultSettings);
|
||||
|
||||
export const parseBoolean = (booleanlike) => ([true, 'true'].includes(booleanlike) ? true : false);
|
||||
|
||||
export function useSettings() {
|
||||
const state = useStore(settingsMap);
|
||||
|
||||
export const $settings = computed(settingsMap, (state) => {
|
||||
const userPatterns = JSON.parse(state.userPatterns);
|
||||
Object.keys(userPatterns).forEach((key) => {
|
||||
const data = userPatterns[key];
|
||||
|
|
@ -105,6 +102,12 @@ export function useSettings() {
|
|||
? true
|
||||
: parseBoolean(state.patternAutoStart),
|
||||
};
|
||||
});
|
||||
|
||||
export const parseBoolean = (booleanlike) => ([true, 'true'].includes(booleanlike) ? true : false);
|
||||
|
||||
export function useSettings() {
|
||||
return useStore($settings);
|
||||
}
|
||||
|
||||
export const setActiveFooter = (tab) => settingsMap.setKey('activeFooter', tab);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue