Wait for exists asynchronous check.

pull/1140/head
ioedeveloper 4 years ago
parent e638250a52
commit 9fb30ce775
  1. 7
      apps/remix-ide/src/app/panels/file-panel.js
  2. 6
      libs/remix-ui/file-explorer/src/lib/actions/fileSystem.ts

@ -188,8 +188,11 @@ module.exports = class Filepanel extends ViewPlugin {
const browserProvider = this._deps.fileProviders.browser const browserProvider = this._deps.fileProviders.browser
const workspacePath = 'browser/' + workspaceProvider.workspacesPath + '/' + name const workspacePath = 'browser/' + workspaceProvider.workspacesPath + '/' + name
const workspaceRootPath = 'browser/' + workspaceProvider.workspacesPath const workspaceRootPath = 'browser/' + workspaceProvider.workspacesPath
if (!browserProvider.exists(workspaceRootPath)) browserProvider.createDir(workspaceRootPath) const workspaceRootPathExists = await browserProvider.exists(workspaceRootPath)
if (!browserProvider.exists(workspacePath)) browserProvider.createDir(workspacePath) const workspacePathExists = await browserProvider.exists(workspacePath)
if (!workspaceRootPathExists) browserProvider.createDir(workspaceRootPath)
if (!workspacePathExists) browserProvider.createDir(workspacePath)
} }
async workspaceExists (name) { async workspaceExists (name) {

@ -182,7 +182,8 @@ export const fileRenamedSuccess = (path: string, removePath: string, files) => {
export const init = (provider, workspaceName: string, plugin, registry) => (dispatch: React.Dispatch<any>) => { export const init = (provider, workspaceName: string, plugin, registry) => (dispatch: React.Dispatch<any>) => {
if (provider) { if (provider) {
provider.event.register('fileAdded', async (filePath) => { provider.event.register('fileAdded', async (filePath) => {
const path = extractParentFromKey(filePath) ? extractParentFromKey(filePath) === '/.workspaces' ? workspaceName : extractParentFromKey(filePath) : workspaceName if (extractParentFromKey(filePath) === '/.workspaces') return
const path = extractParentFromKey(filePath) || workspaceName
const data = await fetchDirectoryContent(provider, path) const data = await fetchDirectoryContent(provider, path)
dispatch(fileAddedSuccess(path, data)) dispatch(fileAddedSuccess(path, data))
@ -191,7 +192,8 @@ export const init = (provider, workspaceName: string, plugin, registry) => (disp
} }
}) })
provider.event.register('folderAdded', async (folderPath) => { provider.event.register('folderAdded', async (folderPath) => {
const path = extractParentFromKey(folderPath) ? extractParentFromKey(folderPath) === '/.workspaces' ? workspaceName : extractParentFromKey(folderPath) : workspaceName if (extractParentFromKey(folderPath) === '/.workspaces') return
const path = extractParentFromKey(folderPath) || workspaceName
const data = await fetchDirectoryContent(provider, path) const data = await fetchDirectoryContent(provider, path)
dispatch(folderAddedSuccess(path, data)) dispatch(folderAddedSuccess(path, data))

Loading…
Cancel
Save