From ced2d12656f969eda0c1abe5dc34ffc1e25d2652 Mon Sep 17 00:00:00 2001 From: Aniket-Engg Date: Thu, 9 Jun 2022 14:44:20 +0530 Subject: [PATCH] check if file to import already exists --- libs/remix-ui/home-tab/src/lib/remix-ui-home-tab.tsx | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/libs/remix-ui/home-tab/src/lib/remix-ui-home-tab.tsx b/libs/remix-ui/home-tab/src/lib/remix-ui-home-tab.tsx index 05f7c32125..2690dfc840 100644 --- a/libs/remix-ui/home-tab/src/lib/remix-ui-home-tab.tsx +++ b/libs/remix-ui/home-tab/src/lib/remix-ui-home-tab.tsx @@ -54,13 +54,16 @@ export const RemixUiHomeTab = (props: RemixUiHomeTabProps) => { contentImport.import( state.importSource, (loadingMsg) => dispatch({ tooltip: loadingMsg }), - (error, content, cleanUrl, type, url) => { + async (error, content, cleanUrl, type, url) => { if (error) { toast(error.message || error) } else { try { - workspace.addExternal(type + '/' + cleanUrl, content, url) - plugin.call('menuicons', 'select', 'filePanel') + if (await workspace.exists(type + '/' + cleanUrl)) toast('File already exists in workspace') + else { + workspace.addExternal(type + '/' + cleanUrl, content, url) + plugin.call('menuicons', 'select', 'filePanel') + } } catch (e) { toast(e.message) }