Merge branch 'main' into jade/dollar_shortcut
This commit is contained in:
commit
af88471f6b
3 changed files with 39 additions and 28 deletions
|
|
@ -1,6 +1,7 @@
|
||||||
import { errorLogger } from '@strudel/core';
|
import { errorLogger } from '@strudel/core';
|
||||||
import { useSettings, storePrebakeScript } from '../../../settings.mjs';
|
import { useSettings, storePrebakeScript } from '../../../settings.mjs';
|
||||||
import { SpecialActionInput } from '../button/action-button';
|
import { SpecialActionInput } from '../button/action-button';
|
||||||
|
import { confirmDialog, SETTING_CHANGE_RELOAD_MSG } from '@src/repl/util.mjs';
|
||||||
|
|
||||||
async function importScript(script) {
|
async function importScript(script) {
|
||||||
const reader = new FileReader();
|
const reader = new FileReader();
|
||||||
|
|
@ -23,7 +24,19 @@ export function ImportPrebakeScriptButton() {
|
||||||
type="file"
|
type="file"
|
||||||
label="import prebake script"
|
label="import prebake script"
|
||||||
accept=".strudel"
|
accept=".strudel"
|
||||||
onChange={(e) => importScript(e.target.files[0])}
|
onChange={async (e) => {
|
||||||
|
const file = e.target.files[0];
|
||||||
|
const confirmed = await confirmDialog(SETTING_CHANGE_RELOAD_MSG);
|
||||||
|
if (!confirmed) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
await importScript(file);
|
||||||
|
window.location.reload();
|
||||||
|
} catch (e) {
|
||||||
|
errorLogger(e);
|
||||||
|
}
|
||||||
|
}}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,13 +1,13 @@
|
||||||
import { defaultSettings, settingsMap, useSettings } from '../../../settings.mjs';
|
import { defaultSettings, settingsMap, useSettings } from '../../../settings.mjs';
|
||||||
import { themes } from '@strudel/codemirror';
|
import { themes } from '@strudel/codemirror';
|
||||||
import { Textbox } from '../textbox/Textbox.jsx';
|
import { Textbox } from '../textbox/Textbox.jsx';
|
||||||
import { isUdels } from '../../util.mjs';
|
import { confirmAndReloadPage, isUdels } from '../../util.mjs';
|
||||||
import { ButtonGroup } from './Forms.jsx';
|
import { ButtonGroup } from './Forms.jsx';
|
||||||
import { AudioDeviceSelector } from './AudioDeviceSelector.jsx';
|
import { AudioDeviceSelector } from './AudioDeviceSelector.jsx';
|
||||||
import { AudioEngineTargetSelector } from './AudioEngineTargetSelector.jsx';
|
import { AudioEngineTargetSelector } from './AudioEngineTargetSelector.jsx';
|
||||||
import { confirmDialog } from '../../util.mjs';
|
import { confirmDialog } from '../../util.mjs';
|
||||||
import { DEFAULT_MAX_POLYPHONY, setMaxPolyphony, setMultiChannelOrbits } from '@strudel/webaudio';
|
import { DEFAULT_MAX_POLYPHONY, setMaxPolyphony, setMultiChannelOrbits } from '@strudel/webaudio';
|
||||||
import { ActionButton, SpecialActionButton } from '../button/action-button.jsx';
|
import { SpecialActionButton } from '../button/action-button.jsx';
|
||||||
import { ImportPrebakeScriptButton } from './ImportPrebakeScriptButton.jsx';
|
import { ImportPrebakeScriptButton } from './ImportPrebakeScriptButton.jsx';
|
||||||
|
|
||||||
function Checkbox({ label, value, onChange, disabled = false }) {
|
function Checkbox({ label, value, onChange, disabled = false }) {
|
||||||
|
|
@ -86,8 +86,6 @@ const fontFamilyOptions = {
|
||||||
galactico: 'galactico',
|
galactico: 'galactico',
|
||||||
};
|
};
|
||||||
|
|
||||||
const RELOAD_MSG = 'Changing this setting requires the window to reload itself. OK?';
|
|
||||||
|
|
||||||
export function SettingsTab({ started }) {
|
export function SettingsTab({ started }) {
|
||||||
const {
|
const {
|
||||||
theme,
|
theme,
|
||||||
|
|
@ -127,11 +125,8 @@ export function SettingsTab({ started }) {
|
||||||
isDisabled={started}
|
isDisabled={started}
|
||||||
audioDeviceName={audioDeviceName}
|
audioDeviceName={audioDeviceName}
|
||||||
onChange={(audioDeviceName) => {
|
onChange={(audioDeviceName) => {
|
||||||
confirmDialog(RELOAD_MSG).then((r) => {
|
confirmAndReloadPage(() => {
|
||||||
if (r == true) {
|
settingsMap.setKey('audioDeviceName', audioDeviceName);
|
||||||
settingsMap.setKey('audioDeviceName', audioDeviceName);
|
|
||||||
return window.location.reload();
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
|
|
@ -141,11 +136,8 @@ export function SettingsTab({ started }) {
|
||||||
<AudioEngineTargetSelector
|
<AudioEngineTargetSelector
|
||||||
target={audioEngineTarget}
|
target={audioEngineTarget}
|
||||||
onChange={(target) => {
|
onChange={(target) => {
|
||||||
confirmDialog(RELOAD_MSG).then((r) => {
|
confirmAndReloadPage(() => {
|
||||||
if (r == true) {
|
settingsMap.setKey('audioEngineTarget', target);
|
||||||
settingsMap.setKey('audioEngineTarget', target);
|
|
||||||
return window.location.reload();
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
|
|
@ -175,12 +167,9 @@ export function SettingsTab({ started }) {
|
||||||
label="Multi Channel Orbits"
|
label="Multi Channel Orbits"
|
||||||
onChange={(cbEvent) => {
|
onChange={(cbEvent) => {
|
||||||
const val = cbEvent.target.checked;
|
const val = cbEvent.target.checked;
|
||||||
confirmDialog(RELOAD_MSG).then((r) => {
|
confirmAndReloadPage(() => {
|
||||||
if (r == true) {
|
settingsMap.setKey('multiChannelOrbits', val);
|
||||||
settingsMap.setKey('multiChannelOrbits', val);
|
setMultiChannelOrbits(val);
|
||||||
setMultiChannelOrbits(val);
|
|
||||||
return window.location.reload();
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
}}
|
}}
|
||||||
value={multiChannelOrbits}
|
value={multiChannelOrbits}
|
||||||
|
|
@ -297,11 +286,8 @@ export function SettingsTab({ started }) {
|
||||||
label="Sync across Browser Tabs / Windows"
|
label="Sync across Browser Tabs / Windows"
|
||||||
onChange={(cbEvent) => {
|
onChange={(cbEvent) => {
|
||||||
const newVal = cbEvent.target.checked;
|
const newVal = cbEvent.target.checked;
|
||||||
confirmDialog(RELOAD_MSG).then((r) => {
|
confirmAndReloadPage(() => {
|
||||||
if (r) {
|
settingsMap.setKey('isSyncEnabled', newVal);
|
||||||
settingsMap.setKey('isSyncEnabled', newVal);
|
|
||||||
window.location.reload();
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
}}
|
}}
|
||||||
disabled={shouldAlwaysSync}
|
disabled={shouldAlwaysSync}
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
import { code2hash, evalScope, hash2code, logger } from '@strudel/core';
|
import { code2hash, errorLogger, evalScope, hash2code, logger } from '@strudel/core';
|
||||||
import { settingPatterns } from '../settings.mjs';
|
import { settingPatterns } from '../settings.mjs';
|
||||||
import { setVersionDefaults } from '@strudel/webaudio';
|
import { setVersionDefaults } from '@strudel/webaudio';
|
||||||
import { getMetadata } from '../metadata_parser';
|
import { getMetadata } from '../metadata_parser';
|
||||||
|
|
@ -107,7 +107,19 @@ export function confirmDialog(msg) {
|
||||||
resolve(confirmed);
|
resolve(confirmed);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
export const SETTING_CHANGE_RELOAD_MSG = 'Changing this setting requires the window to reload itself. OK?';
|
||||||
|
export function confirmAndReloadPage(onSuccess) {
|
||||||
|
confirmDialog(SETTING_CHANGE_RELOAD_MSG).then((r) => {
|
||||||
|
if (r == true) {
|
||||||
|
try {
|
||||||
|
onSuccess();
|
||||||
|
return window.location.reload();
|
||||||
|
} catch (e) {
|
||||||
|
errorLogger(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
//RIP due to SPAM
|
//RIP due to SPAM
|
||||||
// let lastShared;
|
// let lastShared;
|
||||||
// export async function shareCode(codeToShare) {
|
// export async function shareCode(codeToShare) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue