From f8845d7fd5706aa40724067f590b24a0f4eaf0d0 Mon Sep 17 00:00:00 2001 From: filip mertens Date: Mon, 8 Nov 2021 14:21:17 +0100 Subject: [PATCH] fix recorder --- apps/remix-ide/src/app/tabs/runTab/recorder.js | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/apps/remix-ide/src/app/tabs/runTab/recorder.js b/apps/remix-ide/src/app/tabs/runTab/recorder.js index f1f25e1bd9..31eae76d70 100644 --- a/apps/remix-ide/src/app/tabs/runTab/recorder.js +++ b/apps/remix-ide/src/app/tabs/runTab/recorder.js @@ -141,18 +141,20 @@ class RecorderUI extends Plugin { ) } - saveScenario (promptCb, cb) { + async saveScenario (promptCb, cb) { var txJSON = JSON.stringify(this.recorder.getAll(), null, 2) var path = this.fileManager.currentPath() - promptCb(path, input => { + promptCb(path, async input => { var fileProvider = this.fileManager.fileProviderOf(path) if (!fileProvider) return var newFile = path + '/' + input - helper.createNonClashingName(newFile, fileProvider, async (error, newFile) => { - if (error) return cb('Failed to create file. ' + newFile + ' ' + error) - if (!await fileProvider.set(newFile, txJSON)) return cb('Failed to create file ' + newFile) + try { + newFile = await helper.createNonClashingNameAsync(newFile, this.fileManager) + await fileProvider.set(newFile, txJSON) await this.fileManager.open(newFile) - }) + } catch (error) { + if (error) return cb('Failed to create file. ' + newFile + ' ' + error) + } }) } }