From 07bea6da03d3dd8e5cc5df99349af9802bebf0a5 Mon Sep 17 00:00:00 2001 From: Aniket-Engg Date: Mon, 1 Aug 2022 14:27:14 +0530 Subject: [PATCH] show files on folder expansion --- libs/remix-ui/workspace/src/lib/actions/index.ts | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/libs/remix-ui/workspace/src/lib/actions/index.ts b/libs/remix-ui/workspace/src/lib/actions/index.ts index 953a75ba88..fce393a7c8 100644 --- a/libs/remix-ui/workspace/src/lib/actions/index.ts +++ b/libs/remix-ui/workspace/src/lib/actions/index.ts @@ -4,7 +4,7 @@ import Gists from 'gists' import { customAction } from '@remixproject/plugin-api/lib/file-system/file-panel/type' import { displayNotification, displayPopUp, fetchDirectoryError, fetchDirectoryRequest, fetchDirectorySuccess, focusElement, fsInitializationCompleted, hidePopUp, removeInputFieldSuccess, setCurrentWorkspace, setExpandPath, setMode, setWorkspaces } from './payload' import { listenOnPluginEvents, listenOnProviderEvents } from './events' -import { createWorkspaceTemplate, getWorkspaces, loadWorkspacePreset, setPlugin } from './workspace' +import { createWorkspaceTemplate, getWorkspaces, loadWorkspacePreset, setPlugin, workspaceExists } from './workspace' import { QueryParams } from '@remix-project/remix-lib' import { fetchContractFromEtherscan } from '@remix-project/core-plugin' // eslint-disable-line import JSZip from 'jszip' @@ -80,6 +80,7 @@ export const initWorkspace = (filePanelPlugin) => async (reducerDispatch: React. {id: 5, name: 'goerli'} ] let found = false + let filePath const foundOnNetworks = [] for (const network of networks) { const target = `/${network.name}/${contractAddress}` @@ -95,15 +96,15 @@ export const initWorkspace = (filePanelPlugin) => async (reducerDispatch: React. } found = true foundOnNetworks.push(network.name) - await createWorkspaceTemplate('etherscan-code-sample', 'code-template') + if (await workspaceExists('etherscan-code-sample')) workspaceProvider.setWorkspace('etherscan-code-sample') + else await createWorkspaceTemplate('etherscan-code-sample', 'code-template') plugin.setWorkspace({ name: 'etherscan-code-sample', isLocalhost: false }) dispatch(setCurrentWorkspace({ name: 'etherscan-code-sample', isGitRepo: false })) - let filePath count = count + (Object.keys(data.compilationTargets)).length for (filePath in data.compilationTargets) await workspaceProvider.set(filePath, data.compilationTargets[filePath]['content']) - plugin.on('editor', 'editorMounted', async () => await plugin.fileManager.openFile(filePath)) } + plugin.on('editor', 'editorMounted', async () => await plugin.fileManager.openFile(filePath)) plugin.call('notification', 'toast', `Added ${count} verified contract${count === 1 ? '': 's'} from ${foundOnNetworks.join(',')} network${foundOnNetworks.length === 1 ? '': 's'} of Etherscan for contract address ${contractAddress} !!`) } catch (error) { await basicWorkspaceInit(workspaces, workspaceProvider)