From b764cbabbde73168fb6badff4ed49db1a286fbb4 Mon Sep 17 00:00:00 2001 From: Joseph Izang Date: Mon, 12 Aug 2024 12:51:35 +0100 Subject: [PATCH] fix publish to gist bug --- .../workspace/src/lib/actions/index.ts | 6 ++-- .../workspace/src/lib/remix-ui-workspace.tsx | 30 ------------------- 2 files changed, 2 insertions(+), 34 deletions(-) diff --git a/libs/remix-ui/workspace/src/lib/actions/index.ts b/libs/remix-ui/workspace/src/lib/actions/index.ts index 3821814f8b..fc5e64f389 100644 --- a/libs/remix-ui/workspace/src/lib/actions/index.ts +++ b/libs/remix-ui/workspace/src/lib/actions/index.ts @@ -265,7 +265,8 @@ const buildGistPayload = (selectedFiles: { key: string, type: 'file' | 'folder', const files: { [key: string]: { content: string }} = {} for (const file of selectedFiles) { - files[file.key] = { content: file.content } + const resultingSplits = file.key.split('/') + files[resultingSplits[resultingSplits.length - 1]] = { content: file.content } } return files } @@ -290,8 +291,6 @@ export const publishFilesToGist = (arrayOfSelectedFiles: any) => { const gists = new Gists({ token: accessToken }) dispatch(displayPopUp('Creating a new gist ...')) - // console.log('checking this', { gistPayload, gists, params }) - // return gists.create({ description: description, public: true, @@ -299,7 +298,6 @@ export const publishFilesToGist = (arrayOfSelectedFiles: any) => { }, (error, result) => { console.log('what comes back from gist creation', { error, result }) handleGistResponse(error, result) - // throw new Error('Thing didn\'t work as expected!') }) console.log('publishFilesToGistIsDone') } catch (error) { diff --git a/libs/remix-ui/workspace/src/lib/remix-ui-workspace.tsx b/libs/remix-ui/workspace/src/lib/remix-ui-workspace.tsx index 05d23d4fc9..f8cbacb9d1 100644 --- a/libs/remix-ui/workspace/src/lib/remix-ui-workspace.tsx +++ b/libs/remix-ui/workspace/src/lib/remix-ui-workspace.tsx @@ -167,9 +167,7 @@ export function Workspace() { * folders are not handled */ const handlePublishingMultiSelectedFilesToGist = async () => { - // first create a temporary folder to populate selected files try { - // await global.dispatchCreateNewFolder(tempFolderName, ROOT_PATH) const selectedFiles = [] for (const one of feTarget) { if (one.type === 'folder') return @@ -177,35 +175,7 @@ export function Workspace() { selectedFiles.push({ key: one.key, type: one.type, content: content }) } console.log('Files selected', selectedFiles) - // publishFilesToGist(selectedFiles) global.dispatchPublishFilesToGist(selectedFiles) - // console.log('completed') - // await global.dispatchPublishToGist(ROOT_PATH) - // global.plugin.on('finishedGistPublish', async (folderName) => { - // console.log('name of folder', folderName) - // if (folderName === tempFolderName) - // await global.dispatchDeletePath(folderName) - // }) - // const selectedFiles = [] - // let gistFolder = '' - // let tempFolderName = '' - // for (const one of feTarget) { - // if (one.type === 'folder') return - // // const content = await global.plugin.call('fileManager', 'readFile', one.key) - // // selectedFiles.push({ key: one.key, type: one.type, content: content }) - // tempFolderName += one.key - // } - // gistFolder = nameGistFolder(tempFolderName) - // await global.dispatchCreateNewFolder(gistFolder, ROOT_PATH) - // for (const one of feTarget) { - // await copyFile(one.key, gistFolder) - // } - // publishFolderToGist(gistFolder) - // console.log('check this out', { selectedFiles, gistFolder }) - // setTimeout(async () => { - // // await global.dispatchDeletePath([gistFolder]) - // await deletePath([gistFolder]) - // }, 500) } catch (error) { await global.plugin.call('notification', 'toast', 'Could not publish files to gist. There was an error') await global.plugin.call('notification', 'toast', typeof(error) === 'string' ? error : `${console.log(error)} check the console for more details`)