From 4c3159d28bfc15aaeac0c3304ab6bbc5bd034e77 Mon Sep 17 00:00:00 2001 From: yann300 Date: Sun, 18 Feb 2024 22:10:07 +0100 Subject: [PATCH] improve gist --- libs/remix-ui/workspace/src/lib/actions/index.ts | 11 ++++++----- libs/remix-ui/workspace/src/lib/actions/workspace.ts | 4 ++-- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/libs/remix-ui/workspace/src/lib/actions/index.ts b/libs/remix-ui/workspace/src/lib/actions/index.ts index 67787e1d2c..998a39779c 100644 --- a/libs/remix-ui/workspace/src/lib/actions/index.ts +++ b/libs/remix-ui/workspace/src/lib/actions/index.ts @@ -72,9 +72,10 @@ export const initWorkspace = (filePanelPlugin) => async (reducerDispatch: React. dispatch(setWorkspaces(workspaces)) } if (params.gist) { - await createWorkspaceTemplate('code-sample', 'gist-template') - plugin.setWorkspace({ name: 'code-sample', isLocalhost: false }) - dispatch(setCurrentWorkspace({ name: 'code-sample', isGitRepo: false })) + const name = 'gist ' + params.gist + await createWorkspaceTemplate(name, 'gist-template') + plugin.setWorkspace({ name, isLocalhost: false }) + dispatch(setCurrentWorkspace({ name, isGitRepo: false })) await loadWorkspacePreset('gist-template') } else if (params.code || params.url || params.shareCode) { await createWorkspaceTemplate('code-sample', 'code-template') @@ -229,8 +230,8 @@ export const publishToGist = async (path?: string, type?: string) => { const folder = path || '/' try { - const name = extractNameFromKey(path) - const id = name && name.startsWith('gist-') ? name.split('-')[1] : null + const name = await plugin.call('filePanel', 'getCurrentWorkspace') + const id = name && name.startsWith('gist ') ? name.split(' ')[1] : null const packaged = await packageGistFiles(folder) // check for token diff --git a/libs/remix-ui/workspace/src/lib/actions/workspace.ts b/libs/remix-ui/workspace/src/lib/actions/workspace.ts index 31ec69ab99..0bbdf6b368 100644 --- a/libs/remix-ui/workspace/src/lib/actions/workspace.ts +++ b/libs/remix-ui/workspace/src/lib/actions/workspace.ts @@ -345,9 +345,9 @@ export const loadWorkspacePreset = async (template: WorkspaceTemplate = 'remixDe } if (data.files[element].type === 'application/json') { - obj['/' + 'gist-' + gistId + '/' + path] = { content: JSON.stringify(value.content, null, '\t') } + obj['/' + path] = { content: JSON.stringify(value.content, null, '\t') } } else - obj['/' + 'gist-' + gistId + '/' + path] = value + obj['/' + path] = value } plugin.fileManager.setBatchFiles(obj, 'workspace', true, (errorLoadingFile) => { if (errorLoadingFile) {