From cd815d064d04ff503c151e331df94bc414bcae87 Mon Sep 17 00:00:00 2001 From: Felix Roos Date: Fri, 18 Feb 2022 21:56:11 +0100 Subject: [PATCH] dont autolink minirepl --- repl/src/tutorial/MiniRepl.tsx | 9 +-------- repl/src/useRepl.ts | 6 ++++-- 2 files changed, 5 insertions(+), 10 deletions(-) diff --git a/repl/src/tutorial/MiniRepl.tsx b/repl/src/tutorial/MiniRepl.tsx index ba7b02b2..9617d417 100644 --- a/repl/src/tutorial/MiniRepl.tsx +++ b/repl/src/tutorial/MiniRepl.tsx @@ -12,17 +12,10 @@ const defaultSynth = new Tone.PolySynth().chain(new Tone.Gain(0.5), Tone.Destina }); function MiniRepl({ tune, height = 100 }) { - /* const defaultSynth = useMemo(() => { - return new Tone.PolySynth().chain(new Tone.Gain(0.5), Tone.Destination).set({ - oscillator: { type: 'triangle' }, - envelope: { - release: 0.01, - }, - }); - }, []); */ const { code, setCode, activateCode, activeCode, setPattern, error, cycle, dirty, log, togglePlay } = useRepl({ tune, defaultSynth, + autolink: false, }); return (
diff --git a/repl/src/useRepl.ts b/repl/src/useRepl.ts index 91878c75..ffa65f18 100644 --- a/repl/src/useRepl.ts +++ b/repl/src/useRepl.ts @@ -12,7 +12,7 @@ let s4 = () => { .substring(1); }; -function useRepl({ tune, defaultSynth }) { +function useRepl({ tune, defaultSynth, autolink = true }) { const id = useMemo(() => s4(), []); const [code, setCode] = useState(tune); const [activeCode, setActiveCode] = useState(); @@ -30,7 +30,9 @@ function useRepl({ tune, defaultSynth }) { try { const parsed = evaluate(_code); setPattern(() => parsed.pattern); - window.location.hash = '#' + encodeURIComponent(btoa(code)); + if (autolink) { + window.location.hash = '#' + encodeURIComponent(btoa(code)); + } setError(undefined); setActiveCode(_code); } catch (err: any) {