Skip to content

Commit deb4b9d

Browse files
committed
fix gist in params
1 parent fae517c commit deb4b9d

File tree

1 file changed

+3
-6
lines changed

1 file changed

+3
-6
lines changed

src/state.mjs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22

33
const query = new URLSearchParams(document.location.hash.slice(1));
44

5-
let isGist = query.has('gist');
6-
75
const EXTENSIONS = {
86
__proto__: null,
97
script: 'js',
@@ -19,6 +17,7 @@ const initial = new Map([
1917
let state;
2018

2119
if (query.has('gist')) {
20+
initial.set('gist', query.get('gist'));
2221
state = fetch(`https://api.github.com/gists/${query.get('gist')}`)
2322
.then((r) => r.json())
2423
.then((data) => {
@@ -69,8 +68,8 @@ export function updateState() {
6968
return state
7069
.then((s) => {
7170
const params = new URLSearchParams();
72-
if (isGist) {
73-
params.set('gist', query.get('gist'));
71+
if (s.has('gist')) {
72+
params.set('gist', s.get('gist'));
7473
} else {
7574
params.set('code', LZString.compressToBase64(s.get('code')));
7675
params.set('mode', s.get('mode'));
@@ -103,9 +102,7 @@ document.querySelector('#save-to-gist')
103102
features: [...s.get('features')],
104103
},
105104
}),
106-
107105
}).then((r) => r.text());
108-
isGist = true;
109106
s.set('gist', id);
110107
await updateState();
111108
});

0 commit comments

Comments
 (0)