update hash
This commit is contained in:
parent
4caacb0de1
commit
20016fd9aa
4 changed files with 25 additions and 10 deletions
|
|
@ -115,7 +115,7 @@ export function SettingsTab({ started }) {
|
||||||
isTabIndentationEnabled,
|
isTabIndentationEnabled,
|
||||||
isMultiCursorEnabled,
|
isMultiCursorEnabled,
|
||||||
patternAutoStart,
|
patternAutoStart,
|
||||||
prebakeScript,
|
includePrebakeScriptInShare,
|
||||||
} = useSettings();
|
} = useSettings();
|
||||||
const shouldAlwaysSync = isUdels();
|
const shouldAlwaysSync = isUdels();
|
||||||
const canChangeAudioDevice = AudioContext.prototype.setSinkId != null;
|
const canChangeAudioDevice = AudioContext.prototype.setSinkId != null;
|
||||||
|
|
@ -207,7 +207,15 @@ export function SettingsTab({ started }) {
|
||||||
/>
|
/>
|
||||||
</FormItem>
|
</FormItem>
|
||||||
</div>
|
</div>
|
||||||
<ImportPrebakeScriptButton />
|
<FormItem label="Prebake">
|
||||||
|
<ImportPrebakeScriptButton />
|
||||||
|
<Checkbox
|
||||||
|
label="Include prebake script in share"
|
||||||
|
onChange={(cbEvent) => settingsMap.setKey('includePrebakeScriptInShare', cbEvent.target.checked)}
|
||||||
|
value={includePrebakeScriptInShare}
|
||||||
|
/>
|
||||||
|
</FormItem>
|
||||||
|
|
||||||
<FormItem label="Keybindings">
|
<FormItem label="Keybindings">
|
||||||
<ButtonGroup
|
<ButtonGroup
|
||||||
value={keybindings}
|
value={keybindings}
|
||||||
|
|
|
||||||
|
|
@ -63,7 +63,7 @@ async function getModule(name) {
|
||||||
const initialCode = `// LOADING`;
|
const initialCode = `// LOADING`;
|
||||||
|
|
||||||
export function useReplContext() {
|
export function useReplContext() {
|
||||||
const { isSyncEnabled, audioEngineTarget, prebakeScript } = useSettings();
|
const { isSyncEnabled, audioEngineTarget, prebakeScript, includePrebakeScriptInShare } = useSettings();
|
||||||
const shouldUseWebaudio = audioEngineTarget !== audioEngineTargets.osc;
|
const shouldUseWebaudio = audioEngineTarget !== audioEngineTargets.osc;
|
||||||
const defaultOutput = shouldUseWebaudio ? webaudioOutput : superdirtOutput;
|
const defaultOutput = shouldUseWebaudio ? webaudioOutput : superdirtOutput;
|
||||||
const getTime = shouldUseWebaudio ? getAudioContextCurrentTime : getPerformanceTimeSeconds;
|
const getTime = shouldUseWebaudio ? getAudioContextCurrentTime : getPerformanceTimeSeconds;
|
||||||
|
|
@ -218,7 +218,13 @@ export function useReplContext() {
|
||||||
editorRef.current.repl.evaluate(code);
|
editorRef.current.repl.evaluate(code);
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleShare = async () => shareCode(replState.code);
|
const handleShare = async () => {
|
||||||
|
let code = replState.code;
|
||||||
|
if (includePrebakeScriptInShare) {
|
||||||
|
code = prebakeScript + '\n' + code;
|
||||||
|
}
|
||||||
|
shareCode(code);
|
||||||
|
};
|
||||||
const context = {
|
const context = {
|
||||||
started,
|
started,
|
||||||
pending,
|
pending,
|
||||||
|
|
|
||||||
|
|
@ -1,11 +1,10 @@
|
||||||
import { evalScope, hash2code, logger } from '@strudel/core';
|
import { code2hash, 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';
|
||||||
import { isTauri } from '../tauri.mjs';
|
import { isTauri } from '../tauri.mjs';
|
||||||
import './Repl.css';
|
import './Repl.css';
|
||||||
import { createClient } from '@supabase/supabase-js';
|
import { createClient } from '@supabase/supabase-js';
|
||||||
import { nanoid } from 'nanoid';
|
|
||||||
import { writeText } from '@tauri-apps/plugin-clipboard-manager';
|
import { writeText } from '@tauri-apps/plugin-clipboard-manager';
|
||||||
import { $featuredPatterns /* , loadDBPatterns */ } from '@src/user_pattern_utils.mjs';
|
import { $featuredPatterns /* , loadDBPatterns */ } from '@src/user_pattern_utils.mjs';
|
||||||
|
|
||||||
|
|
@ -109,9 +108,8 @@ export function confirmDialog(msg) {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
let lastShared;
|
|
||||||
|
|
||||||
//RIP due to SPAM
|
//RIP due to SPAM
|
||||||
|
// let lastShared;
|
||||||
// export async function shareCode(codeToShare) {
|
// export async function shareCode(codeToShare) {
|
||||||
// // const codeToShare = activeCode || code;
|
// // const codeToShare = activeCode || code;
|
||||||
// if (lastShared === codeToShare) {
|
// if (lastShared === codeToShare) {
|
||||||
|
|
@ -146,9 +144,10 @@ let lastShared;
|
||||||
// });
|
// });
|
||||||
// }
|
// }
|
||||||
|
|
||||||
export async function shareCode() {
|
export async function shareCode(codeToShare) {
|
||||||
try {
|
try {
|
||||||
const shareUrl = window.location.href;
|
const hash = '#' + code2hash(codeToShare);
|
||||||
|
const shareUrl = window.location.origin + window.location.pathname + hash;
|
||||||
if (isTauri()) {
|
if (isTauri()) {
|
||||||
await writeText(shareUrl);
|
await writeText(shareUrl);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
||||||
|
|
@ -51,6 +51,7 @@ export const defaultSettings = {
|
||||||
isCSSAnimationDisabled: false,
|
isCSSAnimationDisabled: false,
|
||||||
maxPolyphony: 128,
|
maxPolyphony: 128,
|
||||||
multiChannelOrbits: false,
|
multiChannelOrbits: false,
|
||||||
|
includePrebakeScriptInShare: true,
|
||||||
};
|
};
|
||||||
|
|
||||||
let search = null;
|
let search = null;
|
||||||
|
|
@ -97,6 +98,7 @@ export function useSettings() {
|
||||||
isPanelOpen: parseBoolean(state.isPanelOpen),
|
isPanelOpen: parseBoolean(state.isPanelOpen),
|
||||||
userPatterns: userPatterns,
|
userPatterns: userPatterns,
|
||||||
multiChannelOrbits: parseBoolean(state.multiChannelOrbits),
|
multiChannelOrbits: parseBoolean(state.multiChannelOrbits),
|
||||||
|
includePrebakeScriptInShare: parseBoolean(state.includePrebakeScriptInShare),
|
||||||
patternAutoStart: isUdels()
|
patternAutoStart: isUdels()
|
||||||
? false
|
? false
|
||||||
: state.patternAutoStart === undefined
|
: state.patternAutoStart === undefined
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue