From f0a888b12bdfb60b49b064182340def1510e12e8 Mon Sep 17 00:00:00 2001 From: Joseph Izang Date: Tue, 6 Aug 2024 15:25:59 +0100 Subject: [PATCH] use dispatch --- .../workspace/src/lib/remix-ui-workspace.tsx | 55 ++++++++++--------- 1 file changed, 28 insertions(+), 27 deletions(-) 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 da15f2e501..05d23d4fc9 100644 --- a/libs/remix-ui/workspace/src/lib/remix-ui-workspace.tsx +++ b/libs/remix-ui/workspace/src/lib/remix-ui-workspace.tsx @@ -170,14 +170,15 @@ export function Workspace() { // 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 - // const content = await global.plugin.call('fileManager', 'readFile', one.key) - // selectedFiles.push({ key: one.key, type: one.type, content: content }) - // } - // console.log('Files selected', selectedFiles) + const selectedFiles = [] + 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 }) + } + console.log('Files selected', selectedFiles) // publishFilesToGist(selectedFiles) + global.dispatchPublishFilesToGist(selectedFiles) // console.log('completed') // await global.dispatchPublishToGist(ROOT_PATH) // global.plugin.on('finishedGistPublish', async (folderName) => { @@ -185,26 +186,26 @@ export function Workspace() { // 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) + // 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`)